select deptno, listagg(ename,',') within group(order by ename)
from scott.emp 
group by deptno
 
    DEPTNO PATH
---------- --------------------------------------------------------------------------------
 10 CLARK,KING,MILLER
 20 ADAMS,FORD,JONES,SCOTT,SMITH
 30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD

select deptno,wm_concat(ename) as path
from scott.emp
group by deptno
 
    DEPTNO PATH
---------- --------------------------------------------------------------------------------
 10 CLARK,MILLER,KING
 20 SMITH,FORD,ADAMS,SCOTT,JONES
 30 ALLEN,JAMES,TURNER,BLAKE,MARTIN,WARD