오라클 행 열 바꾸는거 decode max 안쓰고
카테고리 없음2015. 2. 14. 21:01
반응형
오라클 행 열 바꾸는거 decode max 안쓰고
with t(dt, a, b, c, d, e, f) as
(
select 1101 ,1 ,2 ,3 ,4 ,5 ,6 from dual union all
select 1102, 2, 3, 4, 5, 6, 1 from dual union all
select 1103, 3, 4, 5, 6, 1, 2 from dual union all
select 1104, 4, 5, 6, 1, 2, 3 from dual union all
select 1105, 5, 6, 1, 2, 3, 4 from dual
)
select *
from (
select *
from t
unpivot include nulls
(val for Character in (a,b,c,d,e,f))
)
pivot (max(val) for dt in (1101,1102,1103,1104,1105))
order by Character;
참조 :http://www.oracleclub.com/article/60345
반응형