日期:2014-05-16 浏览次数:20505 次
select * from test where id in (select b.id from test a, test b where a.name = b.name and a.code = b.code group by b.id having count(b.id) > 1) and id not in (select max(id) from test where id in (select b.id from test a, test b where a.name = b.name and a.code = b.code group by b.id having count(b.id) > 1) group by name, code)
select * from test t1 where exists (select 1 from test t2 where t1.code = t2.code and t1.name = t2.name and t1.id != t2.id) and t1.id not in (select max(id) from test group by name, code)