SQL------删除重复数据

 1

delete from ZZ1
where txt in( select txt from ZZ1 group by  txt having count(txt) > 1) 
and ID not in(select max(ID) from ZZ1 group by txt having count(txt) > 1 )

 2

DELETE ZZ1 
WHERE id IN(
SELECT ID  FROM(
    SELECT *,RANK() OVER(PARTITION BY txt ORDER BY ID DESC) AS RowNo
    FROM ZZ1
    )Ranked WHERE Ranked.RowNo>1
);
原文地址:https://www.cnblogs.com/fabao/p/13889476.html