统计每门课程的学生选修人数(超过5人的课程才统计)
select c_id, count(s_id) count_sid from Score group by c_id where count_sid >5
where中不能使用聚合函数
更改成:
select c_id, count(s_id) count_sid from Score group by c_id having count_sid >5
该SQL查询用于从Score表中统计每门课程的学生选修人数,只显示选修人数超过5的课程。通过使用GROUPBY对课程ID分组,然后应用HAVING子句过滤出选修人数大于5的课程。
统计每门课程的学生选修人数(超过5人的课程才统计)
select c_id, count(s_id) count_sid from Score group by c_id where count_sid >5
where中不能使用聚合函数
更改成:
select c_id, count(s_id) count_sid from Score group by c_id having count_sid >5

被折叠的 条评论
为什么被折叠?