Givet det faktum, at du ikke har angivet noget tabelskema, lad os sige, at tabellen ser noget ud som
MyDealersTable
- DealerID
- SomeOtherColumn
- DealerMotherName
- DealerSportInterest
- SomeTimeStamp
Du kan prøve noget lignende
;WITH Dealers AS (
SELECT *,
ROW_NUMBER() OVER(PARTITION BY DealerID ORDER BY SomeTimeStamp DESC) RowID
FROM MyDealersTable
)
DELETE
FROM Dealers
WHERE RowID > 50
Fra MED common_table_expression (Transact-SQL)