ORACLE用多列转多行@[ORACLE用unpovit多列转多行]
ORACLE用多列转多行
将一个对象(name1)多个属性行列转换
原始数据
执行语句
select distinct a.name, a.type, a.t, b.c from
(
select row_number() over(partition by name order by type) rn, name, type, t
from {表名称}
unpivot ((t,c) for type in ((type1,code1) as type1,
(type2, code2) as type2,
(type3, code3) as type3))
)
执行后结果
小白学习,不妥之处,敬请指导。