title: DISTINCT COUNT in SELECT CASE SQL
body: <p>I have a table of reports that include the fields <code>Case</code> (unique number), <code>ISR</code> (Individual Safety Report - unique number) and <code>YearsOld</code>.</p>
  
  <p>There can be more than one ISR for each Case.  I want to count the number of unique Cases within age groups.</p>
  
  <p>This SQL gives me a count of the number of ISRs:</p>
  
  <pre><code>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`
  </code></pre>
  
  <p>is there a way to modify this to count the DISTINCT <code>Cases</code> for these Age Groups?</p>