I'm trying to build a query to get data from 3 tables
Customers, GiveDonations & GiveFundSplit
From Customers (Id, name and address data)
From GiveFundSplit I need to get 2 Sums from the same field (One of Deductable and the other nonDeductable.
Below is as close as I was able to get (which will not execute).
Please, I could really use some help...
SELECT C.CustomerID, C.Name, F.Deductable, N.NonDeductable
FROM (Customers C, GiveDonations D
LEFT JOIN (
SELECT SUM(F.Amount) AS Deductable
FROM GiveFundSplit F
WHERE (F.TaxDeductable = 'True')
) F ON (D.DonationID = F.ContributionID) )
LEFT JOIN (
SELECT SUM(F.Amount) AS NonDeductable
FROM GiveFundSplit N
WHERE (N.TaxDeductable = 'False')
) N ON (D.DonationID = N.ContributionID)
WHERE (C.CustomerID = D.DonorID)
AND (D.DonationDate > '12/31/2003')
AND (D.DonationDate <= '12/31/2004')
Thank you!
tim@tgm.org