一张表中, 查询学生及格和不及格人数

表结构为: --------------------- classnamescore 班级姓名分数 查询每个班级中, 及格和不及格学生的人数 SELECT`class`, SUM(CASE WHEN score>=60 THEN 1 ELSE 0 END) as gt60, SUM(CASE WHEN score>=60 THEN 0 ELSE 1 END) as lt60 FROM tb1 GROUP BY classSELECTclass, SUM( IF(score >= 60, 1, 0) ) as gt, SUM( IF(score < 60, 1, 0 ) ) as lt FROM tb1 GROUP BY class;

    推荐阅读