删除重复记录的最新sql脚本

delete from tb1   where id in(
select t2.minnum from(select MIN(t1.id) as minnum,t1.col1 as ars ,COUNT(1) as cx  from tb1 t1 group by t1.col1
)t2)

select * from tb1 where id in(
select t2.minnum from
(select  min(t.id) as minnum,t.col1,COUNT(1) cx from tb1 t  group by t.col1  having COUNT(t.col1)>1) t2)

只查询有重复的部分

select * from tb1;
11 1
14 2
17 3
18 333
19 4

原文地址:https://www.cnblogs.com/kexb/p/4492316.html