select case when id=1 then name end, case when id=2 then name end, case when id=3 then name end from table;
查询语句中 PIVOT 子 句 和 UNPIVOT 子 句
oracle 11后,有个pivot方法 with t as (select 1 id , '张三' name from dual union all select 2 id ,'李四' name from dual union all select 3 ,'王五' from dual union all select 4, '赵四' from dual)select * from (select id,name from t ) pivot(max(name) for id in (1,2,3,4))
case when id=2 then name end,
case when id=3 then name end
from table;
with t as
(select 1 id , '张三' name from dual
union all
select 2 id ,'李四' name from dual
union all
select 3 ,'王五' from dual
union all
select 4, '赵四' from dual)select * from (select id,name from t ) pivot(max(name) for id in (1,2,3,4))
如果有一个分组列名为codeid,这种pivot语句是怎么个写法学习下