根据表中的status状态计算各各状态的和 - peterchengqi/jygj GitHub Wiki
table status id status summary 1 1 2 2 1 3 3 2 3 4 1 4 5 3 5
select sum(case when status=1 then 1 else 0 end as status_1) as status_1, sum(case when status=2 then 1 else 0 end as status_1) as status_2, sum(case when status=3 then 1 else 0 end as status_1) as status_3 from status;
result [status_1 => 9, status_2=> 3, status_3 =>5]