title: How do I COUNT rows of a GROUP BY query where a condition matches?
body: <p>This is my persons table:</p>
  
  <pre><code>neighborhood  birthyear
  a             1958
  a             1959
  b             1970
  c             1980
  </code></pre>
  
  <p>I'd like to get the <code>COUNT</code> of people in an age group within every neighborhood. For example, if I wanted to get everyone under the age of 18, I would get:</p>
  
  <pre><code>neighborhood  count
  a             0
  b             0
  c             0
  </code></pre>
  
  <p>If I wanted to get everyone over 50, I'd get</p>
  
  <pre><code>neighborhood  count
  a             2
  b             0
  c             0
  </code></pre>
  
  <p>I tried </p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT neighborhood, COUNT(*)
      FROM persons
      WHERE YEAR(NOW()) - persons.birthyear &lt; 18
      GROUP BY neighborhood;
  </code></pre>
  
  <p>but this gives me 0 rows, when instead I want 3 rows with distinct neighborhoods and 0 count for each. How would I accomplish this?</p>