title: Getting a SUM based off the column's relationship with another column (SQL)
body: <p>So let's say you have the following data representing employees within a company.  Column one is their unique ID, column 2 is the ID of their supervisor, and column 3 represents whether or not the employee is over 21.  (Y means they are over 21, N means they are not)</p>
  
  <pre><code>    |Employee ID |Supervisor ID|Over21|
      -----------------------------------
      |1           |1            |Y     | 
      |2           |1            |N     |
      |3           |1            |Y     |
      |4           |2            |Y     |
      |5           |2            |Y     |
      |6           |3            |N     |
      |7           |3            |N     |
  </code></pre>
  
  <p>So, if I wanted to find the number of employees that are over 21, I could do that pretty easily with:</p>
  
  <pre><code>SELECT SUM(CASE WHEN [Over21] IS 'Y' THEN 1 ELSE 0 END)
  </code></pre>
  
  <p>But let's say you want to find <strong>the number of supervisors that have an employee that is over 21</strong>. (In this example it would be 2).   I've been racking my brain trying to figure out a way to write out a way to find that but I've been struggling so far. </p>