1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | WITH data_t AS ( SELECT 1 pk, '1,2,4' code FROM dual UNION ALL SELECT 2, '2' FROM dual UNION ALL SELECT 3, '1,3,4' FROM dual ) , code_t AS ( SELECT '1' code, '학생' name FROM dual UNION ALL SELECT '2' , '담임' FROM dual UNION ALL SELECT '3' , '교직원' FROM dual UNION ALL SELECT '4' , '비회원' FROM dual ) SELECT a.pk , a.code , LISTAGG(b. name , ',' ) WITHIN GROUP ( ORDER BY INSTR( ',' ||a.code|| ',' , ',' ||b.code|| ',' )) name FROM data_t a , code_t b WHERE INSTR( ',' ||a.code|| ',' , ',' ||b.code|| ',' ) > 0 GROUP BY a.pk, a.code ; |