How to make select statement where result is rows combined in comma separated manner based on columns (user & group).
Expected result
USER | GROUP | SUB
-------------------------
3 | 102 | 1,3,2,4,61
CodePudding user response:
This is what LISTAGG
was built for
SELECT t.USER, t.group, LISTAGG (t.sub, ',') WITHIN GROUP (ORDER BY t.pk_id)
FROM your_table t
GROUP BY t.USER, t.GROUP