/ Published in: MySQL
Expand |
Embed | Plain Text
SELECT id, sum(if (`user_type` = 1, 1, 0)) as COUNT_TYPE1, sum(if (`user_type` = 2, 1, 0)) as COUNT_TYPE2, sum(if (`user_type` = 3, 1, 0)) as COUNT_TYPE3, sum(if (`user_type` = 4, 1, 0)) as COUNT_TYPE4 FROM users GROUP BY id
You need to login to post a comment.
