// case when 的使用
select userid, sum(case when status =1 then 1 else 0 end) as '1',
sum(case when status =2 then 1 else 0 end) as '2',
sum(case when status =3 then 1 else 0 end) as '3'
from user group by userid;
mysql根据不同状态统计出现的次数
猜你喜欢
转载自blog.csdn.net/xiaoxinshuaiga/article/details/83212136
今日推荐
周排行