How to find people who have given:
- between xx times in the past number of years
- more than a xx times in the past number of years
the trick is that you need a combination of normal criteria to limit the donations you are looking for and a having clause to count what you have found and eliminate those that don't meet the count.
Normal Criteria
The normal criteria is optional. If you don't specify anything, you will retrieve all donations. Some things you might want to include in criteria are one or more of:
- criteria to eliminate soft credits, prospects, and hard pledges which are not real money - unless you want to count those amounts towards the patrons giving
- donation date range - if you only want to look at a range of years, or only every second year, or only leap years, or anything you want ...
- Donation Campaigns - if you want to limit search to certain campaigns
- Donation actual amount - if you want to limit search to individual donations between a certain range, over a certain range, or anything you want
- belongs to mail list - if you want to find subscribers in your list, or volunteers, or people who bought giver certificates, or people who returned tickets for donations - anything simple or complex that you want relating to the patron
In short, you can limit the donations selected to ANY criteria you could enter (or select all donations)
Having Criteria
The HAVING clause re-examines the set of data is found using the normal criteria. It then imposes a further restriction on the aggregate set of data. Examples could be:
- the data must HAVE a UNIQUE number of fiscal years donated >=2 per patron (the example above) -or-
- the total count of donations must be >6
- the average donation across the number of years selected must be between x and y
- the distinct number of campaigns given to must between x and y
- and much more