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!

How to combine-unique-row-values-into-comma-separated-string for multiple columns in a single query?

3267423Jun 29 2016 — edited Jul 8 2016

Hello everyone,

I have used listagg() as below :

select

listagg( field1, ',')

    within group (order by field1) as field1,

     listagg(field13, ',')

    within group (order by field13) as field13,

listagg(field4, ',')

    within group (order by field4) as field4, 

    listagg(field7, ',')

    within group (order by field7) as field7, 

  listagg(field9, ',')

    within group (order by field9) as field9,   

    listagg(field8, ',')

    within group (order by field8) as field8,

    listagg(field15, ',')

    within group (order by field15) as field15   

from shp_load_match_tb where field6='668972051854' and customer_code='GLID'

group by field6;


  This query is getting the csv of all column values but what we need is to get csv of unique column values. Can anyone suggest what can we do to make it better.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 5 2016
Added on Jun 29 2016
11 comments
4,039 views