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 |
|
shamasm
Starting Member
11 Posts |
Posted - 2011-08-22 : 05:58:47
|
| HI ALL, I need to convert Destination Row to Column and the UserCount as the values for the column ..SELECT RefDestinationID , COUNT(RefUserID) AS UserCount FROM UserDestinationMap GROUP BY RefDestinationID RefDestinationID UserCount ----------- ------------------1 22 13 24 15 16 17 18 3this is the o/p of the query .. i need like this 1 2 3-- -- ----2 1 2 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2011-08-22 : 06:16:01
|
select [1], [2], [3], [4], [5], [6], [7], from (select RefDestinationID, UserCount from @t) p1pivot(max(UserCount) for RefDestinationID in ([1], [2], [3], [4], [5], [6], [7], )) p2Harsh Athalyehttp://www.letsgeek.net/ |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|
|
|