SQL语句去重
删除student表中name重复的记录
1.首先查询出重复的数据
select name,row_number() over(partition by name order by name) as id from Student
(注:按name进行分组排序,row_number()表示name相同情况下也进行排序)
2.删除重复的数据
with ab as(
select * from
(select name,row_number() over(partition by name order by name) as id from Student ) a
where id>1)
delete from ab
此公式Student是表名,name是字段名,套用公式,只要修改有颜色的表名和字段名就行,其他可以不用管。