单字段
1、查询
select * from t_ams_product where fid in (select fid from t_ams_product group by fid having count(fid) > 1)
2、删除
根据id
delete from t_ams_product where (fid) in ( select fid from t_ams_product group by fid having count(fid) > 1) and rowid not in (select min(rowid) from t_ams_product group by fid having count(*) > 1);
根据其他字段
delete from t_ams_product where fpro_code in (select fpro_code from t_ams_product group by fpro_code having count (fpro_code) > 1 ) and fid not in (select min(fid) from t_ams_product group by fpro_code having count(fpro_code) > 1 )
多字段
删除
delete from t_rp_org a where (a.forg_type ,a.forg_name) in (select forg_type ,forg_name from t_rp_org group by forg_type ,forg_name having count() > 1) and rowid not in (select min(rowid) from t_rp_org group by forg_type ,forg_name having count()>1)