I've googled and searched in tek-tips for this issue, but haven't found the answer. I have row data that I need to pivot as columns. Here is sample data:
code codevalue
ProductID 1
ProductName A
ProductID 2
ProductName B
Which I need to have as
ProductID ProductName
1 A
2 B
I'm trying to get the correct syntax:
Thanks for the help!
code codevalue
ProductID 1
ProductName A
ProductID 2
ProductName B
Which I need to have as
ProductID ProductName
1 A
2 B
I'm trying to get the correct syntax:
Code:
SELECT ProductID
,ProductName
FROM
(SELECT ProductID
,ProductName
FROM Product) AS SourceTable
PIVOT
(for ProductID, ProductName in ([0], [1])) AS PivotTable;