Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Flethuseo
Starting Member
2 Posts |
Posted - 2009-10-06 : 14:26:15
|
| Hi,I need to use the pivot function to generate a table of stores and the amount of hours employee has worked for that store from a table named EmpStoreHoursI can generate the table but I get an error:Select StoreId [1],[2],[3],[4] from EmpStoreHours PIVOT (SUM(hours) for EmpId in [1],[2],[3],[4] as WorkHours.The table comes out fine, but some employees don’t work in all the stores, and then I get null values, how can I change those null values for 0 values in the table.Ted. |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-10-06 : 15:01:24
|
| use this (In the SELECT clause) for all the pivot columns where you want to replace NULL with 0:isNull([1],0) as [1]Be One with the OptimizerTG |
 |
|
|
|
|
|