Oracle: Combine multiple results in a subquery into a single comma-separated value [duplicate]
I found this that seems to work. Thoughts?
SELECT SUBSTR (c, 2) concatenated FROM (SELECT SYS_CONNECT_BY_PATH ( myfield, ',') c, r FROM (SELECT ROWNUM ID, myfield, RANK () OVER (ORDER BY ROWID DESC) r FROM mytable ORDER BY myfield) START WITH ID = 1 CONNECT BY PRIOR ID = ID - 1) WHERE r = 1;
11.2 introduced LISTAGG, which unlike WM_CONCAT is documented. We are not on 11.2 yet, so we use a custom aggregate function.