sql server 刪除重複數據 保留id大的

DELETE  FROM [Translation]  where keyid in  
(SELECT T.KeyID FROM [Translation] as T WHERE T.PageID=6088 And T.KeyID<=61866 And
T.TranslationKey IN (SELECT T1.TranslationKey FROM [Translation] as T1 GROUP BY TranslationKey HAVING COUNT(T1.TranslationKey)>1) 

AND T.KeyID NOT IN (SELECT MAX(T2.KeyID) FROM [Translation] as T2 GROUP BY T2.TranslationKey HAVING COUNT(T2.TranslationKey)>1)) 




DELETE  FROM [Translation]  where keyid in  
(SELECT T.KeyID FROM [Translation] as T WHERE T.PageID=6088 And T.KeyID<=61866 And
T.TranslationKey IN (SELECT T1.TranslationKey FROM [Translation] as T1 GROUP BY TranslationKey HAVING COUNT(T1.TranslationKey)>1) 
AND T.KeyID NOT IN (SELECT MAX(T2.KeyID) FROM [Translation] as T2 GROUP BY T2.TranslationKey HAVING COUNT(T2.TranslationKey)>1)) 


發佈了99 篇原創文章 · 獲贊 12 · 訪問量 35萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章