Top donors between two dates without giftaid
###
Financial
###
33712/Any rev02
###
A list of people in descending order of who donated the most for a period where none of the donations were giftaid
###
en_GB
###
$VAR from DATE Donations received between$
$VAR to DATE and$
$VAR cutoff NUMBER Do not show total donations below (0 for all)$

SELECT o.OwnerName, o.ID AS OID, o.OwnerAddress, o.OwnerTown, o.OwnerCounty, o.OwnerPostcode, o.EmailAddress, SUM(od.Donation) AS MoneyTotal
FROM ownerdonation od
INNER JOIN owner o ON od.OwnerID = o.ID 
WHERE od.Date >= '$@from$' AND od.Date <= '$@to$' AND od.IsGiftAid = 0
GROUP BY o.OwnerName, o.OwnerAddress, o.OwnerTown, o.OwnerCounty, o.OwnerPostcode, o.EmailAddress
HAVING SUM(od.Donation) > $@cutoff$ * 100
ORDER BY SUM(od.Donation) DESC
###
$$HEADER
<table border=1>
<thead>
<tr>
<th><b>Donor</b></th>
<th><b>Total Donations</b></th>
</tr>
</thead>
<tbody>
HEADER$$

$$BODY
<tr>
<td><a target="_blank" href="person?id=$OID">$OWNERNAME</a>, $owneraddress, $ownertown, $ownercounty, $ownerpostcode<br/>$emailaddress</td>
<td>$moneytotal</td>
</tr>
BODY$$

$$FOOTER
</tbody>
</table>
FOOTER$$

