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=>总数)

 

posted @ 2013-05-29 22:22  好记性还真不如烂笔头  阅读(3941)  评论(0编辑  收藏  举报