Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Listagg function

santhosh TApr 26 2017 — edited Apr 26 2017

Dear All,

Could you please help me in this below query to get only one concatenated row for DEPENDENTS value.

/* Formatted on 2017/04/26 10:51 (Formatter Plus v4.8.8) */

SELECT a.person_code, a.last_name, first_name, listagg (c.depend_name, ',') within GROUP (ORDER BY c.depend_name) as dependents

FROM fam\_person a, fam\_person\_communication b, cq\_dependents c

WHERE a.person_id = b.person_id

 AND a.person\_code = c.person\_code

 AND a.person\_code = '60050010'

SROUP BY a.person_code, a.last_name, first_name, c.depend_name

Output of the above query:

pastedImage_2.png

Required Output as like below:

pastedImage_6.png

Below is the Result of FAM_PERSON_COMMUNICATION table.

pastedImage_3.png

Below is the Result of CQ_DEPENDENTS table.

pastedImage_5.png

Please suggest me to correct the query.

I am on Oracle 11g 11.2.0.2.0 - 64bit Production

Thanks.

This post has been answered by Sven W. on Apr 26 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 24 2017
Added on Apr 26 2017
17 comments
641 views