联合主键、非主键查询以及去重

 

select * from 表 a where (a.Id,a.seq) in(select Id,seq from 表 group by Id,seq having count(*) > 1)


delete from 表 a where (a.Id,a.seq) in (select Id,seq from 表 group by Id,seq having count(*) > 1) and rowid not in (select min(rowid) from 表 group by Id,seq having count(*)>1)

 

 

SELECT * FROM  T_MATERIAL_DIR WHERE ROWID IN
  ( SELECT MIN(ROWID) RID FROM T_MATERIAL_DIR GROUP BY MDIRNAME)
  
  select *
               from t_material_info
              where rowid in (select min(rowid) rid
                                from t_material_info
                               group by mdirname, mname)

你可能感兴趣的:(Sql)