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
);

 

posted @ 2020-10-28 10:14  法宝  阅读(78)  评论(0编辑  收藏  举报