一条语句删除表中相同的记录

 

--一条语句删除表中相同的记录

--测试数据
Declare @ Table
(
 id  int identity,
 sName varchar(10)
)

Insert into @ Select '张三'
Insert into @ Select '王二'
Insert into @ Select '张三'
Insert Into @ Select '李四'
Insert into @ Select '王二'

Delete from @
where not id  in (select Max(id) from @ Group by sName)

Select * from @


发布了11 篇原创文章 · 获赞 0 · 访问量 5万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章