假设表stu(id,cid,score),分表标识学号、课程号、分数
一门课不及格
select count(*) from stu where score < 60 group by id having count(*) = 1;
二门课不及格
select count(*) from stu where score < 60 group by id having count(*) = 2;
三门课不及格
select count(*) from stu where score < 60 group by id having count(*) = 3;