Home » SQL & PL/SQL » SQL & PL/SQL » A query related to Collapsing nulls /pivoing of data
A query related to Collapsing nulls /pivoing of data [message #300850] Mon, 18 February 2008 04:51 Go to next message
orausern
Messages: 817
Registered: December 2005
Senior Member
Dear Experts,

Following is a requirement that I am trying to resolve…I will be thankful if you can suggest a sql solution for it…

There is a table called person and it has data like this:
SQL> select * from person;

NAME                 FRIEND_NAME                    RELATIVE_NAME
-------------------- ------------------------------ ------------------------------
Ram                  Mohan
Ram                                                 Sohan
Ram                  Deven
Ram                                                 Mona
Praveen              Shyam
Praveen                                             Roma
Praveen              Tushar



Now what I need is:

NAME                 FRIEND_NAME                    RELATIVE_NAME
-------------------- ------------------------------ ------------------------------
Ram                  Mohan,Deven
Ram					Sohan,Mona
Praveen	Shyam,Tushar
Praveen				 Roma


-So for more than one row in the second or third column, they are converted into a single row, comma-seperated for each ‘NAME’ (first column). All columns of this table are varchar2(30).

With thanks,
Nirav
Re: A query related to Collapsing nulls /pivoing of data [message #300862 is a reply to message #300850] Mon, 18 February 2008 06:24 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Search for "pivot".

Almost 600 posts and you don't know that.
Almost 600 posts and you don't how to align your columns.

Regards
Michel

[Updated on: Mon, 18 February 2008 06:26]

Report message to a moderator

Re: A query related to Collapsing nulls /pivoing of data [message #300977 is a reply to message #300862] Mon, 18 February 2008 21:52 Go to previous messageGo to next message
rleishman
Messages: 3724
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Also search on CONCAT_ALL
Re: A query related to Collapsing nulls /pivoing of data [message #301208 is a reply to message #300977] Tue, 19 February 2008 10:20 Go to previous message
orausern
Messages: 817
Registered: December 2005
Senior Member
Thanks. I could get the answer from a detailed example of this in one of Maheer's posts.

[Updated on: Tue, 19 February 2008 10:20]

Report message to a moderator

Previous Topic: merged: extracting query from a procedure
Next Topic: Urgent: DBMS_SQL.PARSE - Raising ORA-01009: missing mandatory parameter
Goto Forum:
  


Current Time: Thu Dec 08 12:12:19 CST 2016

Total time taken to generate the page: 0.22001 seconds