1.构造虚拟表
select 'a' 字段1,'100' 字段2 from dual
union all
select 'b' 字段2,'200' 字段2 from dual2.虚拟表为
字段1 字段2
a 100
b 200
3.行转列
with query1 as
(
select 'a' 字段1,'100' 字段2 from dual
union all
select 'b' 字段2,'200' 字段2 from dual
)
select 字段1,
max(case when 字段1='a' then 字段2 else null end) as a,
max(case when 字段1='b' then 字段2 else null end) as b
from query1
group by 字段14.结果表为
字段1 A B
a 100
b 100
1万+

被折叠的 条评论
为什么被折叠?



