title: MySQl using COUNT with CASE statement
body: <p>in my mysql database i have <code>instagram_actions_histories</code> table with two important column as <code>action_type</code> and <code>action_name</code>, now i want to use count and case statement to get count of <code>id</code>s column, for example:</p>
  
  <p>count of all <code>id</code>s when <code>action_type</code> equal <code>1</code> and <code>action_name</code> equal 'like'</p>
  
  <pre><code>select `account_id`,
  
  count(case when action_type = 1 and action_name='like' then id else 0 END) as `like`,
  count(case when action_type = 1 and action_name='superLike' then id else 0 END) as `superLike`,
  count(case when action_type = 2 then id else 0 END) as `follow`, 
  
  from `instagram_actions_histories` 
  where `instagram_actions_histories`.`account_id` in (1) 
  group by `account_id`
  </code></pre>
  
  <p>unfortunately i get wrong result as all of outputs are same, for example:</p>
  
  <pre><code>account_id  like    superLike    follow
  1           1282    1282         1282
  </code></pre>
  
  <p>correct result was should be:</p>
  
  <pre><code>account_id  like    superLike    follow
  1           1282    20           10
  </code></pre>