My table has multiple values per person, which I'm trying to combine into one row. Here's the query:
select TABLE.ID, TABLE.NAME, listagg(TABLE.HOLD, ',') within group (order by TABLE.HOLD) as hold_codes from TABLE where TABLE.ACTIVE_HOLD_IND ='Y' and TABLE.HOLD in('S2', 'S3', 'CO', 'WO', 'PP') group by TABLE.ID, TABLE.NAME, TABLE.HOLD order by 2 ID |NAME |HOLD_CODES _____________________________ 111 |Tom |S2 222 |Jerry |CO 222 |Jerry |S2 333 |Olive |S2,S2 444 |Popeye |CO 444 |Popeye |PP 444 |Popeye |S2 555 |Homer |S2,S2 666 |Marge |S2 I'm trying to combine each ID on one line. Right now, the query only picks up the rows of duplicates.
Any suggestions would be appreciated.