아래의 데이터를 결과값처럼 나타낼수 있을까요? 고수님들의 조언 부탁드립니다.
예제)
'a1' gubun, '2023-06-01' day
'a1' gubun, '2023-06-02' day
'a1' gubun, '2023-06-03' day
'a2' gubun, '2023-06-02' day
'a2' gubun, '2023-06-04' day
==> 결과
gubun, day1, day2, day3, day4
'a1', '2023-06-01', '2023-06-02', '2023-06-03'
'a2', '' '2023-06-02', '' ,'2023-06-04' 로 결과값이 나올게 할 수 있을까요
WITH t AS ( SELECT 'a1' gubun, '2023-06-01' day FROM dual UNION ALL SELECT 'a1', '2023-06-02' FROM dual UNION ALL SELECT 'a1', '2023-06-03' FROM dual UNION ALL SELECT 'a2', '2023-06-02' FROM dual UNION ALL SELECT 'a2', '2023-06-04' FROM dual ) SELECT * FROM (SELECT gubun, day , DENSE_RANK() OVER(ORDER BY day) dr FROM t ) PIVOT (MIN(day) day FOR dr IN (1, 2, 3, 4, 5)) ;