Using LISTAGG:
SELECT deptno,listagg(ename,',') within group (order by deptno) employees
from emp group by deptno;
Using COLLECT:
SELECT DEPTNO, TO_STRING(CAST( COLLECT(ENAME) AS VARCHAR2_NTT)) AS EMPLOYEES FROM EMP GROUP BY DEPTNO
SELECT deptno,listagg(ename,',') within group (order by deptno) employees
from emp group by deptno;
Using COLLECT:
SELECT DEPTNO, TO_STRING(CAST( COLLECT(ENAME) AS VARCHAR2_NTT)) AS EMPLOYEES FROM EMP GROUP BY DEPTNO
No comments:
Post a Comment