title: Mysql count for every month
body: <p>I have a mysql table that looks like this:</p>
  
  <pre><code>id      level      time
  1         1     2014-02-19 04:33:04
  2         1     2014-03-19 04:33:04
  3         1     2014-03-20 04:33:04
  4         2     2014-03-21 04:53:04
  5         1     2014-07-19 04:33:04
  6         2     2014-07-19 04:33:04
  7         1     2014-07-19 04:33:04
  8         1     2014-08-19 04:33:04
  </code></pre>
  
  <p>I wanted to get the results for level 1 like this:</p>
  
  <pre><code>level1count    year    month
    0            2014      1
    1            2014      2
    2            2014      3
    0            2014      4
    0            2014      5
    0            2014      6
    2            2014      7
    1            2014      8
    0            2014      9
    0            2014      10
    0            2014      11
    0            2014      12
  </code></pre>
  
  <p>I tried this query , but does not give result for every month</p>
  
  <pre><code>SELECT YEAR(time) AS year, MONTH(time) AS month, COUNT(DISTINCT id) AS count FROM users where level = '1' GROUP BY year, month
  </code></pre>