Home » SQL & PL/SQL » SQL & PL/SQL » sql query to convert columns into rows
sql query to convert columns into rows [message #222379] Sat, 03 March 2007 12:36 Go to next message
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?

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

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

Thanks in advance
Re: sql query to convert columns into rows [message #222380 is a reply to message #222379] Sat, 03 March 2007 12:45 Go to previous message
Messages: 24964
Registered: January 2009
Location: SoCal
Senior Member
oracle "pivot query"
Previous Topic: sweep to delete rcords from big table
Next Topic: SELECT qry
Goto Forum:

Current Time: Thu Oct 27 04:33:53 CDT 2016

Total time taken to generate the page: 0.10737 seconds