SQL Service数据查询操作 统计每门课程的选课人数及不及格人数

2025-03-22 22:03:12
推荐回答(2个)
回答1:

select c.cnum,
c.cname,
count(1) "选课人数",
sum(case
when sc.score < 60 then
1
else
0
end) "不及格人数"
from course c, sections s, sc
where s.cnum = c.cnum
and sc.secnum = s.secnum
group by c.cnum, c.cname

回答2:

可以使用子查询