Pivoting

Last Post 27 Apr 2006 06:09 AM by Shafiq. 0 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
Shafiq
New Member
New Member

--
27 Apr 2006 06:09 AM
Hi,

I was just testing the Pivoting feature in SQL 2005 and just want to know if this is possible

Select STORE, Code1, Code2, Code3
from dbo.Changes
PIVOT (SUM(TotalValue) FOR Code in (Code1, Code2, Code3)) AS PVT

I dono't want to specify the Column Header (Code1, Code2, Code3), it should take whatever available in my code table

Select Code from Code

It is possible that my Changes table will have only 2 codes at a given time but actual Code table has 5 codes. I just want to show all available codes in the code table no matter if they not available in changes table.

Thanks
Shafiq




Acceptable Use Policy
---