Posted by Plamen Ratchev on 03/30/07 02:31
"Ed Murphy" <emurphy42@socal.rr.com> wrote in message
news:460c63e2$0$24701$4c368faf@roadrunner.com...
>
> I think SQL Server 2005 has a built-in pivoting function, but I've
> never used it so I don't know the syntax.
Here is how it can be done with PIVOT in SQL Server 2005:
SELECT [Product A],
[Product B],
[Product C]
FROM Products
PIVOT (SUM(RankID) FOR [Name] IN ([Product A],
[Product B],
[Product C])) AS P
I find the PIVOT syntax to be not so intuitive (unlike UNPIVOT which is
easier to use and understand).
Plamen Ratchev
http://www.SQLStudio.com
[Back to original message]
|