题目
涉及的表格
1、student表
2、teacher表
3、course表
4、score表
1、查询每个学生的选课情况。显示(学号、课程号)
select sno as 学号,cno as 课程号
from score
group by sno,cno
2、统计助教的人数。
select count(prof) as 助教人数
from teacher
where prof = '助教'
3、查询每门课程的最高分。
select cno,max(grade) as 最高分
from score
group by cno
4、查询每个学生所选课程的最高分。(显示学号、最高分)
select sno as 学号,max(grade) as 最高分
from score
5、统计有多少门课程被选修。
select count(distinct cno) as 被选修课程数
from score
6、查询每门课程的平均成绩。(显示课程号、平均成绩)
select cno as 课程号,avg(grade) as 平均成绩
from score
group by cno
7、统计有超过4个学生选修的课程的课程号。
select cno
from score
group by cno
having count(cno) > 4
8、查询平均分超过80的课程的课程名。
select cno
from score
group by cno
having avg(grade) > 80
9、查询哪些班的人数超过3人。
select class
from student
group by class
having count(class) >= 3