比如一张简单的用户表
create table UserInfo(Id int primary key identity(1,1),Name varchar(10) not null,CreateTime datetime)
同一个用户名注册了多次,现在要删除这些重复的数据,保留最初注册的数据
delete from UserInfo where Name in(select Name from UserInfo group by Name having COUNT(*)>1) and id not in (select min(id) from UserInfo group by Name having COUNT(*)>1)
如果觉得《删除重复数据sql语句》对你有帮助,请点赞、收藏,并留下你的观点哦!