擷取某字段或幾個字段有重複的資料,可限定重複幾條
select field1,field2 from table group by field1,field2 having count(field1)>1
擷取某字段不重複的最新記錄
select top * from table a where id in(select max(id) from table b group by field) order by id desc
擷取某字段的重複數
select count(field) from table group by field having count(field)>1
擷取不重複的記錄
select field1,field2 from table group by field1,field2
删除重複記錄
delete from from table a where id not in(select max(id) from table b group by field)