0
如何從查詢中引用的表中刪除記錄,例如,下面是我的查詢,它返回了正確數量的結果,但我希望從中刪除這些記錄在查詢中引用的同一個表。如何根據查詢結果刪除記錄
;with cte as (select *,
row_number() over (partition by c.[Trust Discharge], c.[AE Admission], c.[NHS Number]
order by c.[Hospital Number]) as Rn,
count(*) over (partition by c.[Trust Discharge], c.[AE Admission], c.[NHS Number]) as cntDups
from CommDB.dbo.tblNHFDArchive as c)
Select * from cte
Where cte.Rn>1 and cntDups >1
哪些?那些'.Rn> 1'和'cntDups> 1'? – McNets
是的,我想從滿足上述條件的CommDB.dbo.tblNHFDArchive中刪除。 – Simon
嗯,我認爲你想要做的是在這裏回答http://stackoverflow.com/questions/812512/faster-way-to-delete-matching-rows – am05mhz