使用数据库HR scheme的表作为示例。
SELECT t.employee_id,listagg(t.job_id,',') within GROUP (order by t.job_id) FROM job_history t GROUP BY t.employee_id;
EMPLOYEE_ID LISTAGG(T.JOB_ID,')WITHINGROUP(ORDERBYT.JOB_ID) 1 101 AC_ACCOUNT,AC_MGR 2 102 IT_PROG 3 114 ST_CLERK 4 122 ST_CLERK 5 176 SA_MAN,SA_REP 6 200 AC_ACCOUNT,AD_ASST 7 201 MK_REP
原文链接:/oracle/207094.html