Here is what i have:
Payment# Account# Payment Date
1 10000 5/1/2007
2 10001 5/1/2007
3 10002 5/5/2007
4 10000 5/7/2007
The result that I would like to based on the above:
Payment# Account# Payment Date
1 10000 5/1/2007
2 10001 5/1/2007
3 10002 5/5/2007
The result would be to get ridd off the last record since it s a payment
done for an account with a prior payment, so keep the prior payment and get
rid off the recent one, but at the same time keep all the other ones
(accounts with single payment) (I have a table that has 30000 rows) so i
think instead of Max i will use Min but how i can do it with 30000 rows
It makes me really, really nervous to *delete all records that a payment
occurred* even if there were a prior payment. I know if I were a customer of
yours, and sent you two checks, and was later told "We only have records that
you paid once" I'd be more than a little bit annoyed. That's why I'm being so
persistant with this question:
Do you want to permanently, irrevokably, delete all payments more recent than
the oldest?
If so, you can run a Delete query:
DELETE * FROM yourtable
WHERE [Payment#] IN
(SELECT [Payment#] FROM yourtable AS X
WHERE X.[Account#] = yourtable.[Account#]
AND X.[Payment Date] > yourtable.[Payment Date])
This Subquery will look at every record in the table which has one or more
later payments for the same account, and delete that payment.
Make a backup of your database before you do this - deletion is permanent and
there is no "undelete"!
John W. Vinson [MVP]