title: MySql count() how many of type per month and return 0 if no records found
body: <p>I am trying to create a report for how many claimed=0 and how many claimed=1 per month and return 0 if no records. It took me forever and so far no luck! 
  This is what I've got so far:</p>
  
  <p>A short version of the table:</p>
  
  <pre><code>+----+------------+---------+
  | id | date_in    | claimed |   
  +----+------------+---------+
  | 1  | 2015-01-10 | 0       |
  | 2  | 2015-01-09 | 1       |
  | 3  | 2014-12-19 | 0       |
  | 4  | 2014-11-07 | 0       |
  | 5  | 2014-11-01 | 1       |
  +----+------------+---------+
  </code></pre>
  
  <p>The query:</p>
  
  <pre><code>SELECT MONTH( date_in ) as date_in, COUNT( date_in ) AS total_items , claimed
      FROM item
      WHERE date_in &gt;= NOW() - INTERVAL 1 YEAR
      GROUP BY MONTH(date_in), claimed
  </code></pre>
  
  <p>This query gives me this result:</p>
  
  <pre><code>+---------+-------------+---------+
  | date_in | total_items | claimed |     
  +---------+-------------+---------+
  | 1       | 1           | 0       |
  | 2       | 1           | 0       |
  | 2       | 1           | 1       |
  | 5       | 4           | 0       |
  | 5       | 4           | 1       |
  | 6       | 479         | 0       |
  | 6       | 167         | 1       |
  | 7       | 729         | 0       |
  | 7       | 211         | 1       |
  | 8       | 790         | 0       |
  | 8       | 229         | 1       |
  | 9       | 307         | 0       |
  | 9       | 66          | 1       |
  +---------+-------------+---------+
  </code></pre>
  
  <p>But what I want is:</p>
  
  <pre><code>+---------+-------------+---------+
  | date_in | total_items | claimed |     
  +---------+-------------+---------+
  | 1       | 1           | 0       |
  | 1       | 0           | 1       |
  | 2       | 0           | 0       |
  | 2       | 0           | 1       |
  | 3       | 0           | 0       |
  | 3       | 0           | 1       |
  | 4       | 0           | 0       |
  | 4       | 0           | 1       |
  | 5       | 4           | 0       |
  | 5       | 4           | 1       |
  | 6       | 479         | 0       |
  | 6       | 167         | 1       |
  | 7       | 729         | 0       |
  | 7       | 211         | 1       |
  | 8       | 790         | 0       |
  | 8       | 229         | 1       |
  | 9       | 307         | 0       |
  | 9       | 66          | 1       |
  | 10      | 0           | 0       |
  | 10      | 0           | 1       |
  | 11      | 0           | 0       |
  | 11      | 0           | 1       |
  | 12      | 0           | 0       |
  | 12      | 0           | 1       |
  +---------+-------------+---------+
  </code></pre>