>Thank you gentleman that is exactly what I needed! One more question regarding the same data set. How can I retrieve just the last or most recent contribution? I know I can use MAX() for the contribution date but will that only return the contribution date or the amount also?
Hi Jeff,
You can get most recent contribution with MAX() but not the way you're thinking.
SELECT * FROM Contributions c1
WHERE NOT EXISTS (
SELECT * FROM Contributions c2
WHERE c2.cDonors_id = c1.cDonors_id
AND c2.ContributionDate > c1.ContributionDate)
SELECT * FROM Contributions c1
WHERE ContributionDate = (
SELECT MAX(ContributionDate) FROM Contributions c2
WHERE c2.cDonors_id = c1.cDonors_id )
--sb--