直接查询合格人数以及没有合格的人数的数量是多少
select sum(case when score<=80 then 1 else 0 end) as 不合格人数,
sum(case when score>80 then 1 else 0 end) as 合格人数
from user
在一张表里查询学生的某一科成绩合格或者优秀展示出来如下:
SELECT StaffName, (CASE WHEN Chinese >=22 THEN '优秀'
WHEN Chinese >=23 THEN '及格'ELSE '不及格'END) 语文,
(case when math >=43 then'优秀'
WHEN math >=41 THEN'及格' ELSE '不及格'END) 数学,
(case when English >=38 then '优秀'
WHEN English >=30 THEN '及格'ELSE '不及格'END) 英语
FROM user