表A
name type
1 A
1 B
1 A
1 C
拆分后变成
name1 type1 name2 type2 name3 type3
1 A 1 B 1 C
1 A
ORA-32039:递归WITH子句必须具有列别名列表
报错呀
没报错呀
with a as (select 1 name, 'A' type from dual
union all select 1, 'B' from dual
union all select 1, 'A' from dual
union all select 1, 'C' from dual),
t as (select a.name, a.type, row_number() over(partition by type order by name) r from a)
select max(case when type='A' then name end) name1, max(case when type='A' then type end) type1,
max(case when type='B' then name end) name2, max(case when type='B' then type end) type2,
max(case when type='C' then name end) name3, max(case when type='C' then type end) type3
from t
group by r
哪来的递归?
那只查了一列,其余的几列怎么办
怎么弄呢?