一條語句刪除表中相同的記錄

 

--一條語句刪除表中相同的記錄

--測試數據
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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章