Delete all records with most recent date

NZArchie

Registered User.
Local time
Tomorrow, 00:53
Joined
May 9, 2011
Messages
84
Has anyone got TOP syntax working in a DELETE query? I am trying to delete all records with the most recent date. The syntax works with SELECT eg

Code:
SELECT TOP 1 Payments.DateOfPayment, Payments.*
FROM Payments
ORDER BY Payments.DateOfPayment;

But doesn't port to DELETE. Clues?
 
What you need to do is use your Select Top query as the basis for your Delete query.
 
I would use a subquery like ...
Code:
DELETE FROM Payments 
WHERE DateOfPayment = (
  SELECT MAX(DateOfPayment) FROM Payments 
  )
 

Users who are viewing this thread

Back
Top Bottom