January 4, 2009 at 10:38 am
Hi All,
I have a table where I need to convert columns to Rows. The data looks like
Description Rule1 Rule2 Rule3
Default1 100 150 200
Default1 50 100 200
Default2 150 400 120
Default2 250 300 120
I want it to change to
NewDescription NewRule Value
Default1 Rule1 150
Default1 Rule2 250
Default1 Rule3 400
Default2 Rule1 400
Default2 Rule2 700
Default2 Rule3 420
Note that 'Value' is the sum of 'Rule1' for Default1 in the original table and so on.
Thanks.
January 4, 2009 at 11:16 am
Here are two (2) excellent articles by Jeff Moden which will explain how to perform what you need along with detailed sample code:
January 6, 2009 at 9:59 am
See the link below for a good example of doing an 'UNPIVOT' with SQL 2000
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply