title: Trying to query data set multiple times
body: <p>What am I doing wrong? Trying to output two COUNTs and need to Group by Grade.  </p>
  
  <pre><code>SELECT grade, COUNT(DISTINCT ID) AS total, SUM(case when course like 'AS%'      
  then 1 else 0 END) Total_As FROM schedule GROUP BY Grade ORDER BY Grade ASC 
  </code></pre>
  
  <p>Only problem is that Total_As is counting grade for multiple instances. Just need to count once if employee took at least one training with Course 'AS%'. The script is currently counting every single 'AS%' taken by employee(ID). Need the "case" part to only count the employee(ID) once to indicate that employee took at least one 'AS%' training or 0 if they did not attend. SUM should not count the employee more than once. </p>