Length of Stay by Species (Shelter Only)
###
Statistics
###
33018/Any rev02
###
Shows time on shelter by species for current shelter animals
###
en
###
SELECT
a.AnimalName, a.ShelterCode, a.ID AS AID,
s.SpeciesName, e.ReasonName,
a.DateBroughtIn, a.TimeOnShelter, a.DaysOnShelter, a.AnimalAge
FROM animal a
INNER JOIN species s ON s.ID = a.SpeciesID
INNER JOIN entryreason e ON e.ID = a.EntryReasonID
WHERE a.Archived = 0 AND NonShelterAnimal = 0 AND NOT EXISTS(SELECT ID FROM adoption WHERE IsPermanentFoster=1 AND AnimalID=a.ID)
ORDER BY s.SpeciesName, a.DateBroughtIn
###
$$HEADER
HEADER$$

$$GROUP_SpeciesName
$$HEAD
<h2>$SpeciesName</h2>
<table border="1">
<thead>
<tr>
<th>Code</th>
<th>Name</th>
<th>Age</th>
<th>Entry Category</th>
<th>Entered</th>
<th>Days In Care</th>
</tr>
</thead>
<tbody>
$$FOOT
</tbody>
</table>
<p>Total $SpeciesName: {COUNT.SpeciesName}, Average: {AVG.DaysOnShelter.2} days</p>
GROUP$$

$$BODY
<tr>
<td>$SHELTERCODE</td>
<td><a target="_blank" href="animal?id=$AID">$ANIMALNAME</a></td>
<td>$ANIMALAGE</td>
<td>$REASONNAME</td>
<td>$DATEBROUGHTIN</td>
<td>$DAYSONSHELTER</td>
</tr>
BODY$$

$$FOOTER
FOOTER$$

