Home » SQL & PL/SQL » SQL & PL/SQL » column to rows
column to rows [message #437125] Thu, 31 December 2009 03:03 Go to next message
newuser1
Messages: 4
Registered: December 2009
Location: pune
Junior Member
I have following table tb1

ID cd1 cd2 cd3
1 a b c
2 r t y



The output should be as follow and then i want to insert into tb2

ID code
1 a
1 b
1 c
2 r
2 t
2 y

please tell how i can do this in oracle
Re: column to rows [message #437126 is a reply to message #437125] Thu, 31 December 2009 03:09 Go to previous messageGo to next message
ramoradba
Messages: 2454
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
Search for UNPIVOT
Provide your Oracle version (4 digits).

sriram Smile
Re: column to rows [message #437127 is a reply to message #437126] Thu, 31 December 2009 03:11 Go to previous messageGo to next message
newuser1
Messages: 4
Registered: December 2009
Location: pune
Junior Member
i am working on oracle 10g
Re: column to rows [message #437130 is a reply to message #437125] Thu, 31 December 2009 03:24 Go to previous message
Michel Cadot
Messages: 64102
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This is a FAQ, please search before posting.

Use a row generator (line 1 to 3), join your table with it, display the column you want depending og the line.

Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version with 4 decimals.

Post a workingTest case: create table and insert statements along with the result you want with these data.

Regards
Michel
Previous Topic: Issues Oracle Data Source
Next Topic: How to find out last DML operation in a table which does not have date field
Goto Forum:
  


Current Time: Fri Dec 02 14:32:53 CST 2016

Total time taken to generate the page: 0.37876 seconds