Home » SQL & PL/SQL » SQL & PL/SQL » How to write SQL Query to get desire output (oracle 12c)
How to write SQL Query to get desire output [message #676325] Fri, 31 May 2019 06:39 Go to next message
shawaj
Messages: 89
Registered: January 2016
Member
Hi All,

I have a table PP(Cid,Pid). This table has parent - chield relationship between column cid and pid.

I need output like
Rownumber   list
1           UK,DDN,HWR,RKE
2           UP,SRE,NGL,TPR



create table pp(Cid varchar2(30),PID varchar2(30));

insert into pp values('UP','');
insert into pp values('SRE','UP');
insert into pp values('TPR','SRE');
insert into pp values('NGL','SRE');
insert into pp values('UK','');
insert into pp values('HWR','UK');
insert into pp values('DDN','UK');
insert into pp values('RKE','HWR');
COMMIT;

Re: How to write SQL Query to get desire output [message #676327 is a reply to message #676325] Fri, 31 May 2019 09:48 Go to previous messageGo to next message
John Watson
Messages: 8922
Registered: January 2010
Location: Global Village
Senior Member
Is this a college homework question?

You'll need constraints to define the parent-child relationship if you want to get full marks.
What SQL have you tried so far?
Re: How to write SQL Query to get desire output [message #676328 is a reply to message #676325] Fri, 31 May 2019 10:06 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

SYS_CONNECT_BY_PATH.

[Updated on: Fri, 31 May 2019 10:07]

Report message to a moderator

Re: How to write SQL Query to get desire output [message #676343 is a reply to message #676328] Sun, 02 June 2019 23:38 Go to previous message
shawaj
Messages: 89
Registered: January 2016
Member
ok thanks
Previous Topic: varchar2 byte or char semantics
Next Topic: select START_TIME = TO_DATE returns 0
Goto Forum:
  


Current Time: Fri Mar 29 06:03:17 CDT 2024