create table test_abcd(a int,b int,c varchar2(100));
insert into test_abcd values(1,2,'abced');
insert into test_abcd values(1,2,'efg');
insert into test_abcd values(1,2,'hig');
insert into test_abcd values(3,2,'hig');
insert into test_abcd values(3,2,'eiw');
select * from test_abcd
select a, b, max(first_name), max(sec_name), max(third_name)
from (select a,
b,
decode(row_cnt, 1, c) first_name,
decode(row_cnt, 2, c) sec_name,
decode(row_cnt, 3, c) third_name
from (select a,
b,
c,
row_number() over(partition by a, b order by c) row_cnt
from test_abcd) s)
group by a, b;
阅读(778) | 评论(0) | 转发(0) |