select class,
sum(case score >=60 then 1 else 0 end) as '及格人数',
sum(case score < 60 then 1 else 0 end) as '不及格人数'
from student group by class 

解决方案 »

  1.   

    select class,
    (select count(*) from student where class=stu.class and score >=60 ) as '及格人数',
    (select count(*) from student where class=stu.class and score <60 ) as '及格人数',
    from student stu group by class
      

  2.   

    哦,写错了。更正:
    select class,
    (select count(*) from student where class=stu.class and score >=60 ) as '及格人数',
    (select count(*) from student where class=stu.class and score <60 ) as '不及格人数',
    from student stu group by class