1、查找表中多余的重复记录
select * from 表 a where (a.Id,a.seq) in(select Id,seq fromgroup by Id,seq having count(*) > 1)   --a.Id+a.seq唯一
select *
     from bi_network_znf a
    where (a.eqp_ip, a.create_time) in
          (select aa.eqp_ip, aa.create_time
             from bi_network_znf aa
            group by aa.eqp_ip, aa.create_time
           having count(1) > 1)
    order by a.eqp_ip;

 

 

 
2、删除表中多余的重复记录,只留有rowid最小的记录
delete from 表 a where (a.Id,a.seq) in (select Id,seq fromgroup by Id,seq having count(*) > 1) and rowid not in (select min(rowid) fromgroup by Id,seq having count(*)>1)
 select *
    /*delete*/ from bi_network_znf a
    where (a.eqp_ip, a.create_time) in
          (select aa.eqp_ip, aa.create_time
             from bi_network_znf aa
            group by aa.eqp_ip, aa.create_time
           having count(1) > 1)
     and a.rowid not in (select min(rowid)
             from bi_network_znf aa
            group by aa.eqp_ip, aa.create_time
           having count(1) > 1)
   order by a.eqp_ip --删除时需要注释掉
   ;
    commit;