Conver columns to rows in oracle

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
rprasanna28
Participant
Posts: 10
Joined: Fri May 12, 2006 12:31 am

Conver columns to rows in oracle

Post by rprasanna28 »

I have a table with the following data in SQL



SNO NAMES

------ -----------------

1 prasanna

1 lakshmi

1 Ravikumar

2 raja

2 lakshmi

2 natrajan

3 deepika

3 bidri

3 G



And I need the output as following using SQL query



SNO FNAME MNAME LNAME

1 prasanna Lakshmi Ravikumar

2 Raja Lakshmi natrajan

3 Deepika bidri G




If any one of U find the solution please let me know.
Mike
Premium Member
Premium Member
Posts: 1021
Joined: Sun Mar 03, 2002 6:01 pm
Location: Tampa, FL

Post by Mike »

It is not possible with the data you have provided. How do you identify which row corresponds to which name? How do you identify which row is the "first" row for a given SNO. In other words, you have no way to order your names. If you figure out some way to order your rows, then a search of the forum for vertical pivot should reveal some DataStage solutions.

Mike
meena
Participant
Posts: 430
Joined: Tue Sep 13, 2005 12:17 pm

Post by meena »

Hi,
Check with Row Merger active plugin stage.Do a search on Row merger stage in the forum. And move this post to server from parallel.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Search for "vertical pivot" for this is what you are trying to accomplish.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

If the number of records for each group will be only 3, then its possible by using mod function and some corelated subquery. But it is more simple to accomplish from datastage.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

I did something like this a few months back. Check out thispost for more details.
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply