合 MSSQL删除重复记录
Tags: SQL Server
1 2 3 4 5 6 7 8 9 | create table Student( ID varchar(10) not null, Name varchar(10) not null, ); insert into Student values('1', 'zhangs'); insert into Student values('2', 'zhangs'); insert into Student values('3', 'lisi'); insert into Student values('4', 'lisi'); insert into Student values('5', 'wangwu'); |
删除Name重复多余的行,每个Name仅保留1行数据
1、查询表中Name 重复的数据
1 | select Name from Student group by Name having count(Name) > 1 |