WITH T AS ( SELECT '마농' AS NM, '1' AS NO FROM DUAL UNION ALL SELECT '부쉬맨' AS NM, '1' AS NO FROM DUAL UNION ALL SELECT '농부지기' AS NM, '2' AS NO FROM DUAL UNION ALL SELECT '비주류' AS NM, '2' AS NO FROM DUAL UNION ALL SELECT '클라나드' AS NM, '2' AS NO FROM DUAL UNION ALL SELECT '아발란체' AS NM, '3' AS NO FROM DUAL ) SELECT * FROM t
NM NO
마농 1
부쉬맨 1
농부지기 2
비주류 2
클라나드 2
아발란체 3
요 데이터를 같은 번호일때 이름을 한컬럼에 붙이고 싶습니다.
NM NO
마농 , 부쉬맨, 농부지기 1
비주류 , 클라나드 2
아발란체 3
이런식으로 말이죠
항상 많이 배워가고있습니다.
고수님들의 조언 부탁드리겠습니다.
감사합니다.
WITH T AS
( SELECT '마농' AS NM, '1' AS NO FROM DUAL UNION ALL
SELECT '부쉬맨' AS NM, '1' AS NO FROM DUAL UNION ALL
SELECT '농부지기' AS NM, '2' AS NO FROM DUAL UNION ALL
SELECT '비주류' AS NM, '2' AS NO FROM DUAL UNION ALL
SELECT '클라나드' AS NM, '2' AS NO FROM DUAL UNION ALL
SELECT '아발란체' AS NM, '3' AS NO FROM DUAL
)
SELECT LISTAGG(NM,',') WITHIN GROUP(ORDER BY NO), NO
FROM T
GROUP BY NO;
이런식으로로 할 수 있을 듯 합니다..