W
William Wisnieski
Hello Everyone,
I'm helping out a non-profit school with their database. They would like to
know the last gift made by each donor, the donor name, and the gift amount.
I built a query based on two tables. The donor name is from the first table
[Gen_info]. The gift [Date] and [Gift] are in the second table [Gift
Detail].
The query works except for one problem. It will return the proper number of
records with the most recent gift date as long as I don't add the [gift]
field (which is the dollar amount). As soon as I add the [gift] field it
gives me all the gifts for each donor instead of the most recent. The gift
amount is a critical piece the administrators want to see.
Here is the code I have that works:
SELECT Gen_info.ID, Gen_info.FirstName, Gen_info.LastName, Max([Gift
Detail].Date) AS MaxOfDate
FROM Gen_info INNER JOIN [Gift Detail] ON Gen_info.ID = [Gift Detail].ID
GROUP BY Gen_info.ID, Gen_info.FirstName, Gen_info.LastName;
Here is the code that does not work when I add the [gift] field.
SELECT Gen_info.ID, Gen_info.FirstName, Gen_info.LastName, [Gift
Detail].Gift, Max([Gift Detail].Date) AS MaxOfDate
FROM Gen_info INNER JOIN [Gift Detail] ON Gen_info.ID = [Gift Detail].ID
GROUP BY Gen_info.ID, Gen_info.FirstName, Gen_info.LastName, [Gift
Detail].Gift;
Thanks for your help,
William
I'm helping out a non-profit school with their database. They would like to
know the last gift made by each donor, the donor name, and the gift amount.
I built a query based on two tables. The donor name is from the first table
[Gen_info]. The gift [Date] and [Gift] are in the second table [Gift
Detail].
The query works except for one problem. It will return the proper number of
records with the most recent gift date as long as I don't add the [gift]
field (which is the dollar amount). As soon as I add the [gift] field it
gives me all the gifts for each donor instead of the most recent. The gift
amount is a critical piece the administrators want to see.
Here is the code I have that works:
SELECT Gen_info.ID, Gen_info.FirstName, Gen_info.LastName, Max([Gift
Detail].Date) AS MaxOfDate
FROM Gen_info INNER JOIN [Gift Detail] ON Gen_info.ID = [Gift Detail].ID
GROUP BY Gen_info.ID, Gen_info.FirstName, Gen_info.LastName;
Here is the code that does not work when I add the [gift] field.
SELECT Gen_info.ID, Gen_info.FirstName, Gen_info.LastName, [Gift
Detail].Gift, Max([Gift Detail].Date) AS MaxOfDate
FROM Gen_info INNER JOIN [Gift Detail] ON Gen_info.ID = [Gift Detail].ID
GROUP BY Gen_info.ID, Gen_info.FirstName, Gen_info.LastName, [Gift
Detail].Gift;
Thanks for your help,
William