Countif in MySQL


/ Published in: MySQL
Save to your folder(s)



Copy this code and paste it in your HTML
  1. id,
  2. sum(if (`user_type` = 1, 1, 0)) as COUNT_TYPE1,
  3. sum(if (`user_type` = 2, 1, 0)) as COUNT_TYPE2,
  4. sum(if (`user_type` = 3, 1, 0)) as COUNT_TYPE3,
  5. sum(if (`user_type` = 4, 1, 0)) as COUNT_TYPE4
  6. FROM users

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.