title: Adding a WHERE clause to a JOIN statement
body: <p>I have 2 tables, employees and holidays.</p>
  
  <p>I am trying to select a list of employees, their allowed holiday and their remaining holiday left after looking at holidays entered for <strong>this year</strong>.</p>
  
  <p>The tables look like this (important rows shown only)</p>
  
  <pre><code>employees
      id,
      name,
      allowed_holiday
  
  holiday
      id,
      employee,
      num_days,
      date_to
  </code></pre>
  
  <p>I have the current query that finds these values fine, but I want to add a WHERE clause to only count holiday against the employee if date_to > xxxx-09-01 AND &lt; xxxx-09-01.</p>
  
  <pre><code>    SELECT 
          e.id,
          e.name,
          e.allowed_holiday,
          (e.allowed_holiday - SUM(h.num_days)) AS remaining
      FROM
          employees AS e
      LEFT JOIN 
          holiday AS h
      ON
          h.employee = e.id
      GROUP BY
          e.name
      ORDER BY 
          e.name ASC
  </code></pre>
  
  <p>I'm not sure where to add the WHERE clause for this though without it removing employees from the data with no holiday listed.</p>