WITH DT AS
(
SELECT '20180101' AS DATE_KEY ,'11' AS COL1 ,'A' AS COL2 ,'1A' AS COL3 UNION ALL
SELECT '20180202' AS DATE_KEY ,'22' AS COL1 ,'B' AS COL2 ,'2B' AS COL3 UNION ALL
SELECT '20180303' AS DATE_KEY ,'33' AS COL1 ,'C' AS COL2 ,'3C' AS COL3 UNION ALL
SELECT '20180404' AS DATE_KEY ,'44' AS COL1 ,'D' AS COL2 ,'4D' AS COL3 UNION ALL
SELECT '20180505' AS DATE_KEY ,'55' AS COL1 ,'E' AS COL2 ,'5E' AS COL3 UNION ALL
SELECT '20180606' AS DATE_KEY ,'66' AS COL1 ,'F' AS COL2 ,'6F' AS COL3
)
SELECT *
,RANK() OVER(ORDER BY DATE_KEY) AS RK
FROM DT
;
DATE_KEY COL1 COL2 COL3
---------------------------------------------------------------------------------------------------
20180101 11 A 1A
20180202 22 B 2B
20180303 33 C 3C
20180404 44 D 4D
20180505 55 E 5E
20180606 66 F 6F
위 데이터를 RK 기준으로 가로로 나타내고 싶습니다.
↓
RK1 RK2 RK3 RK4 RK5 RK6
----------------------------------------------------------------------------------------------------------------------
11 22 33 44 55 66
A B C D E F
1A 2B 3C 4D 5E 6F
어떻게 해야 할까요?
|