title: MySQL IFNULL not returning default value
body: <pre>id    category    active
  ------------------------
  1     1           1
  2     3           0
  3     3           1
  4     3           1
  5     1           0
  </pre>
  
  <p>I want to select <code>total count of each category</code> and <code>count of active in each cateogry</code>.</p>
  
  <p>Since there's no category=2, I used IFNULL, but it didn't return 0</p>
  
  <pre>SELECT
      IFNULL(COUNT(id), 0) AS total,
      SUM(CASE WHEN active = 1 THEN 1 ELSE 0 END) AS active
  FROM
      table
  WHERE
      category IN (1,2,3)
  GROUP BY
      category</pre>
  
  <p>The result returned 2 arrays, instead of 3 as expected</p>
  
  <pre>// result from category=1
  Array
  (
      [total] => 2
      [active] => 1
  )
  //  result from category=3
  Array
  (
      [total] => 3
      [active] => 2
  )</pre>
  
  <p>How can I get category=2 into the result</p>
  
  <pre>//  result from category=2
  Array
  (
      [total] => 0
      [active] => 0
  )</pre>