August 25, 2008 at 12:26 pm
Looking for techniques people use for pivoting data. I have done pivoting various ways in the past like subselects, pivot command, etc.. but I am trying to see how other people do this as I am struggling with some performance issues.
My scenario.
26 columns.
Column 1 = ID
The remaining 25 columns are sets of 5 duplicates. For example Type1Price, Type2Price, Type3Price, Type1Amount, Type2Price, Type3Price....etc. This query does not need to be dynamic, and the Type Description can be hard coded.
I want the results as follows
ID, Type, Price, Amount
1, "Type A Desc", 5.99, 100
2, "Type B Desc", 2.09, 99
August 25, 2008 at 1:40 pm
Jeff Moden just published an article on this site relating to this topic. It specifically addresses the performance differences.
http://www.sqlservercentral.com/articles/T-SQL/63681/%5B/url%5D
That would be a good place to start.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply