日期:2014-05-17 浏览次数:20883 次
create table test (col_a number,col_b number);
insert into test values(1,1);
insert into test values(1,2);
insert into test values(1,3);
insert into test values(2,4);
insert into test values(2,5);
select AA.*
from test AA,
(select col_a, max(col_b) col_b
from test
where col_a in
(select col_a
from (select col_a, count(distinct col_b)
from test
group by col_a
having count(distinct col_b) > 1) temp)
group by col_a) tt
where AA.col_a = tt.col_a
and AA.col_b < tt.col_b;
------解决方案--------------------
看来又理解错了,楼主是要删除重复记录。总是被你的删除重复列给弄晕了,如下:
Delete From T Where (a, b) NOT IN (Select A, max(B) as B From T Group By A)