Customer Support Language
 
HomeKnowledge BaseCampaignMaxCampaignMax query to show payments distributed by Year/Appeal
Information
Article ID120
Created On6/6/2005
Modified6/6/2005
Share With Others
CampaignMax query to show payments distributed by Year/Appeal
The following query will show payment distributions by Year and Appeal for payments in the given date range:

SELECT
yr.YearDesc as Year,
ap.AppealDesc as Appeal,
SUM(di.DistributionAmount) AS TotalDistributed
FROM
camDistributions di,
camPayments py,
camPledges pl,
camAppeals ap,
camYears yr
WHERE
/* JOIN - to get payment at the payment date */
di.PaymentID = py.PaymentID
/* JOIN - to get to the pledge distributed to */
AND di.PledgeID = pl.PledgeID
/* JOIN - to get the appeal desc */
AND pl.AppealID = ap.AppealID
/* JOIN - to get the year desc */
AND ap.YearID = yr.YearID
/* FILTER - to limit to given dates */
AND py.PaymentDate >= '01-JAN-2004'
AND py.PaymentDate <= '31-MAR-2004'
GROUP BY
yr.YearDesc,
ap.AppealDesc

Note the filter on PaymentDate can be changed.