Home » SQL & PL/SQL » SQL & PL/SQL » How to transpose columns into rows.
How to transpose columns into rows. [message #115602] Tue, 12 April 2005 19:09 Go to next message
newbie_3
Messages: 3
Registered: April 2005
Junior Member
Hello,

Does anybody know a method to transpose columns into rows. Appreciate if anybody can provide any ideas or suggestions.

ex:
col1 col2 col3 col4 col5
----------------------------
2005 2004 2003 area1 brand1

result should be:
col1 col2 col3
-----------------
2005 area1 brand1
2004 area1 brand1
2003 area1 brand1

Regards,
Radhika.
Re: How to transpose columns into rows. [message #115605 is a reply to message #115602] Tue, 12 April 2005 20:18 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9101
Registered: November 2002
Location: California, USA
Senior Member
scott@ORA92> select * from your_table
  2  /

      COL1       COL2       COL3 COL4  COL5
---------- ---------- ---------- ----- ------
      2005       2004       2003 area1 brand1


scott@ORA92> select col1 as col1, col4 as col2, col5 as col3
  2  from   your_table
  3  union all
  4  select col2 as col1, col4 as col2, col5 as col3
  5  from   your_table
  6  union all
  7  select col3 as col1, col4 as col2, col5 as col3
  8  from   your_table
  9  order  by col1 desc
 10  /

      COL1 COL2  COL3
---------- ----- ------
      2005 area1 brand1
      2004 area1 brand1
      2003 area1 brand1

scott@ORA92> 


Re: How to transpose columns into rows. [message #115653 is a reply to message #115605] Wed, 13 April 2005 08:26 Go to previous message
newbie_3
Messages: 3
Registered: April 2005
Junior Member
ThankYou!!! so much.

Regards,
Radhika.
Previous Topic: Find FMX names which are connected in the database
Next Topic: SQL Group by clause issue
Goto Forum:
  


Current Time: Sun Dec 22 08:53:40 CST 2024