查询成绩比该课程平均成绩高的学生的学号、课程号及成绩sql
第一:查询成绩比课程01平均成绩高的学号、课程和成绩code
select Sno,Cno,Degree from SC where Degree > ( select AVG(Degree) from SC where Cno = 'C01' );
第二:查询成绩比全部课程平均成绩高的学号、课程号、成绩class
select Sno,Cno,Degree from SC where Degree >( select AVG(Degree) from SC where Cno = ( select distinct Cno from SC ) );
查询选修了所有课程的学生姓名select
没有这样的课程这位学生没有选查询
select Sname from Student where not exists( select * from SC where where SC.Sno = Student.Sno and not exists( select * from Course where Course.Cno = SC.Cno ) );
分别用子查询和链接查询,求“C02”号课程在80分以上的学生信息di
select * from Student where Cno in ( select Cno from SC where Cno = 'C02' );