|
vijays3
Constraint Violating Yak Guru
354 Posts |
Posted - 2012-05-22 : 17:31:40
|
| [code]create table tab ([Time] varchar(50),NumCase int,code int)insert into tab([Time],NumCase,code)select '15h00 - 16h00',1,41union allselect '15h00 - 16h00',1,42union all select '16h00 - 17h00',3,43union allselect '17h00 - 18h00',1,44union allselect '13h00 - 14h00',2,45union allselect '14h00 - 15h00',1,46union allselect '13h00 - 14h00',1,47select * from tabselect [time]as [time Period],isnull([41],0)as [41], isnull([42],0) as [42], isnull([43],0) as [43] , isnull([44],0) as [44], isnull([45],0)as [45], isnull([46],0) as [46], ISNULL([47],0) as [47] from (select [time],numcase,code from tab) tpivot( max(numcase) for code in([41],[42],[43],[44],[45],[46],[47])) Pvt[/code]Vijay is here to learn something from you guys. |
 |
|