sql query to convert columns into rows [message #222379] |
Sat, 03 March 2007 12:36 |
balaji23_d
Messages: 123 Registered: February 2007
|
Senior Member |
|
|
I am trying to convert 4 rows into a single column...
There are 27 Ptypes, 6 Regions, and 4 Tiers
Is there a way to convert the existing table into the desired table?
Existing.....
PType Region Tier Value
---------------------------------------------------------
RT01 R1 T1 RT1R1T1
RT01 R2 T1 RT1R2T1
RT01 R3 T1 RT1R3T1
RT01 R4 T1 RT1R4T1
RT01 R5 T1 RT1R5T1
RT01 R6 T1 RT1R6T1
RT01 R1 T2 RT1R1T2
RT01 R2 T2 RT1R2T2
RT01 R3 T2 RT1R3T2
RT01 R4 T2 RT1R4T2
RT01 R5 T2 RT1R5T2
RT01 R6 T2 RT1R6T2
etc
Desired
Ptype/TierR1 R2 R3 R4 R5 R6
-----------------------------------------------------------------
RT01/T1 RT1R1T1 RT1R2T1 RT1R3T1 RT1R4T1 RT1R5T1 RT1R6T1
RT01/T2 RT1R1T2 RT1R2T2 RT1R3T2 RT1R4T2 RT1R5T2 RT1R6T2
RT01/T3 RT1R1T3 RT1R2T3 RT1R3T3 RT1R4T3 RT1R5T3 RT1R6T3
RT01/T4 RT1R1T4 RT1R2T4 RT1R3T4 RT1R4T4 RT1R5T4 RT1R6T4
RT02/T1 RT2R1T1 RT2R2T1 RT2R3T1 RT2R4T1 RT2R5T1 RT2R6T1
RT02/T2 RT2R1T2 RT2R2T2 RT2R3T2 RT2R4T2 RT2R5T2 RT2R6T2
RT02/T3 RT2R1T3 RT2R2T3 RT2R3T3 RT2R4T3 RT2R5T3 RT2R6T3
RT02/T4 RT2R1T4 RT2R2T4 RT2R3T4 RT2R4T4 RT2R5T4 RT2R6T4
etc
Thanks in advance
|
|
|
|