17,377
社区成员
发帖
与我相关
我的任务
分享
select uu,
max(decode(type, 1, data)) "1",
max(decode(type, 2, data)) "2",
max(decode(type, 10, data)) "10"
from tbname --tbname换成你的表名就OK了
group by uu;
SQL> with tmp as
2 (
3 select 'aa' uu, 1 type, 209 data from dual
4 union all
5 select 'aa' uu, 2 type, 414 data from dual
6 union all
7 select 'aa' uu, 10 type, 53 data from dual
8 union all
9 select 'bb' uu, 1 type, 93 data from dual
10 union all
11 select 'bb' uu, 2 type, 893 data from dual
12 union all
13 select 'bb' uu, 10 type, 834 data from dual
14 )
15 select uu,
16 max(decode(type, 1, data)) "1",
17 max(decode(type, 2, data)) "2",
18 max(decode(type, 10, data)) "10"
19 from tmp
20 group by uu;
UU 1 2 10
-- ---------- ---------- ----------
aa 209 414 53
bb 93 893 834