mysql sql中查找成绩及格与不及格的人数
数据表:create table 'score'
('sno' int,
`score` int
);
统计成绩及格与不及格的人数;
用 case when .. then .. else .. end
==========================
select sno,
sum(case when score >=60 then 1 else 0 end) as 'good',
sum(case when score < 60 then 1 else 0 end) as 'bad'
from 'score'
==============
查询结果为 array(sno=>号码,good=>总数,bad=>总数)