[원본]
[결과]
위와 같이 결과를 뿌리고 싶은데 아이디어가 안떠오르네요... ㅠㅠ
조언 부탁드립니다. ㅠㅠ
WITH t AS ( SELECT 167 c1, 'A' c2, '' c3, '' c4 FROM dual UNION ALL SELECT 167, 'B', '', '' FROM dual UNION ALL SELECT 167, '', 'C', '' FROM dual UNION ALL SELECT 167, '', 'D', '' FROM dual UNION ALL SELECT 167, '', 'E', '' FROM dual UNION ALL SELECT 167, '', '', 'F' FROM dual ) SELECT c1 , MIN(c2) c2 , MIN(c3) c3 , MIN(c4) c4 FROM (SELECT c1, c2, c3, c4 , ROW_NUMBER() OVER( PARTITION BY CASE WHEN c2 IS NOT NULL THEN 1 WHEN c3 IS NOT NULL THEN 2 WHEN c4 IS NOT NULL THEN 3 END ORDER BY c1, c2, c3 ) rn FROM t ) GROUP BY c1, rn ORDER BY c1, rn ;
너무너무 감사합니다. ㅠㅠ
큰 도움 되었습니다.