Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

PIVOT columns and replace null values with 0

Language: Layout:
View schema
Execution time: 0,03 sec, rows selected: 7, rows affected: 4, absolute service time: 0,17 sec 
fork mode |  history
   CodeGenerated
1 select Department , [2017-07-07 18:17:25] = isnull([2017-07-07 18:17:25],0) , [2017-07-08 18:17:25] = isnull([2017-07-08 18:17:25],0) , [2017-07-09 18:17:25] = isnull([2017-07-09 18:17:25],0) from (select * from #Daysoftheweek) x pivot (avg(TotalUtilized)for DayoftheWeek in ([2017-07-07 18:17:25], [2017-07-08 18:17:25], [2017-07-09 18:17:25])) p
   Department 2017-07-07 18:17:25 2017-07-08 18:17:25 2017-07-09 18:17:25
1 cicu 0 0 0
2 er 0 0 0
3 icu 0 1 1

    
                
λ
.NET NoSQL database for rapid development