안녕하세요? 좋은 하루입니다.
아래와 같이 쿼리로 가능한가요 ?
COL1 COL2
A 8801
A 8802
A 8803
B 8805
B 8809
C 8891
C 8892
C 8893
C 8894
.........
-----------------------------------------
SQL 쿼리 결과
A 8801 / 8802 / 8803
B 8805 / 8809
C 8891 / 8892 / 8893 / 8894
.......
위와 같이 SQL 쿼리로 코딩이 가능한지 문의 드립니다.
항상 도움 감사합니다.
WITH T AS ( SELECT 'A' COL1 , '8801' COL2 FROM DUAL UNION ALL SELECT 'A' COL1 , '8802' COL2 FROM DUAL UNION ALL SELECT 'A' COL1 , '8803' COL2 FROM DUAL UNION ALL SELECT 'B' COL1 , '8805' COL2 FROM DUAL UNION ALL SELECT 'B' COL1 , '8809' COL2 FROM DUAL UNION ALL SELECT 'C' COL1 , '8891' COL2 FROM DUAL UNION ALL SELECT 'C' COL1 , '8892' COL2 FROM DUAL UNION ALL SELECT 'C' COL1 , '8893' COL2 FROM DUAL UNION ALL SELECT 'C' COL1 , '8894' COL2 FROM DUAL ) SELECT COL1 , LISTAGG(COL2,'/') WITHIN GROUP (ORDER BY COL2) VAL FROM T GROUP BY COL1