- 1、查询表中Name 重复的数据
- 2、有唯一列,通过唯一列最大或最小方式删除重复记录
- 3、无唯一列使用ROW_NUMBER()函数删除重复记录参考链接
https://www.cnblogs.com/springsnow/p/10334469.html参考链接
select columns from table
group by column having count(column)>1;
delete from table
where column1 in
(select column1 from table group by column1 having count(column1)>1)
and column2 not in
(select max(column2 ) from table group by column1 having count(column1)>1)
delete t from (
select *, row_number() over(partition by column1 order by column2) as r_n
from table
)t
where t.r_n > 1