10
I have a table of reports that include the fields Case (unique number), ISR (Individual Safety Report - unique number) and YearsOld.
There can be more than one ISR for each Case. I want to count the number of unique Cases within age groups.
This SQL gives me a count of the number of ISRs:
SELECT
COUNT(CASE WHEN `YearsOld` = -2) THEN 1 END) `No Report`,
COUNT(CASE WHEN `YearsOld` BETWEEN 0 AND 5) THEN 1 END) `0 to 5`
COUNT(CASE WHEN `YearsOld` BETWEEN 6 AND 12) THEN 1 END) `6 to 12`
FROM `Demographics`
is there a way to modify this to count the DISTINCT Cases for these Age Groups?