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 |
|
w1102157
Yak Posting Veteran
80 Posts |
Posted - 2012-07-15 : 17:31:59
|
| Hi Guysi am doing a task at work where i need to present the data in a pivot for examplecurrently the data is like the blowtype Name countopen TT 567open AA 56 closed TT 34closed AA 100i need to present the above data likeTT TT AA AA open closed Open Closed567 34 56 100Is there any way i can do this?thank you |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-07-15 : 22:01:16
|
| [code]SELECT SUM(CASE WHEN type = 'open' AND Name ='TT' THEN [count] ELSE 0 END) AS TTOpen, SUM(CASE WHEN type = 'closed' AND Name ='TT' THEN [count] ELSE 0 END) AS TTClosed, SUM(CASE WHEN type = 'open' AND Name ='AA' THEN [count] ELSE 0 END) AS AAOpen, SUM(CASE WHEN type = 'closed' AND Name ='AA' THEN [count] ELSE 0 END) AS AAClosedFROM Table[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|