I need assistance with a query.
The query will include fields from two tables, “Client” and “Donations” with a one to many relationship.
The results I would like to receive from the query are the records from the Client table that do not have a donation within the last six months.
My query SQL is:
SELECT DISTINCT Client.SSNbrClient, Client.LastName, Client.FirstName, Donation.Date, Donation.Amount
FROM Client INNER JOIN Donation ON Client.SSNbrClient = Donation.SSNbrClient
WHERE (((Donation.Date)<DateAdd("m",-6,Date())))
ORDER BY Client.SSNbrClient, Donation.Date;
Sample results:
SS# Last First Date Amount
111-11-1111 Jackson Tom 1/5/2002 $500.00
111-11-1111 Jackson Tom 2/15/2003 $200.00
111-11-1111 Jackson Tom 3/25/2004 $100.00
222-22-2222 Franks Jane 6/12/2002 $100.00
222-22-2222 Franks Jane 1/12/2004 $250.00
333-33-3333 Smith Sam 2/25/2004 $500.00
My problem is:
The query identifies the correct records but I would like to eliminate the duplicate records leaving only the ones with the most current donation date.
Such as:
SS# Last First Date Amount
111-11-1111 Jackson Tom 3/25/2004 $100.00
222-22-2222 Franks Jane 1/12/2004 $250.00
333-33-3333 Smith Sam 2/25/2004 $500.00
I thought the keyword, distinct would work, but it did not.
Your help will be greatly appreciated.
Regards
Ron