查詢成績比該課程平均成績高的學生的學號、課程號及成績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' );