한쪽을 아래와 같이 변경후
조인으로 풀어 보세요
SELECT SUBSTR(MAX(SYS_CONNECT_BY_PATH(NAME,',')),2) NAME, CD
FROM (SELECT ROW_NUMBER() OVER(PARTITION BY CD ORDER BY NAME) RN, CD, NAME
FROM (
SELECT 'A' CD, '가' NAME FROM DUAL UNION ALL
SELECT 'A' CD, '나' NAME FROM DUAL UNION ALL
SELECT 'A' CD, '다' NAME FROM DUAL UNION ALL
SELECT 'A' CD, '라' NAME FROM DUAL UNION ALL
SELECT 'B' CD, '마' NAME FROM DUAL UNION ALL
SELECT 'B' CD, '바' NAME FROM DUAL))
CONNECT BY RN = PRIOR RN + 1
AND CD = PRIOR CD
START WITH RN = 1
GROUP BY CD