比如一张简单的用户表
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)