学生表 S(SN0,SNAME) 其中SNO:学号 SNAME:学生姓名
教师表 T(TNO,TNAME,SCNO) 其中TNO:工号 TNAME:教师姓名 SCNO:教授课程
成绩表 SC(SCNO,SCNAME,SNO,SCGRADE) 其中SCNO:课程代号 SCNAME:课程名 SCGRADE:课程成绩
1:找出没有选修李伟老师课程的所有同学的姓名;
2:找出平均成绩最高的同学的姓名及每门功课的成绩;
3:找出至少有两门(含两门)功课不及格的同学的姓名及不及格课程的成绩;
请用SQL语句实现上面的查询!
1: select sname from s where sno in (select sno from sc where scno not in(select scno from t where tname='李伟'))
2: select sname,scname,scgrade from s,sc where s.sno=sc.sno and sc.sno=
(select top 1 sno from sc group by sno order by avg(scgrade) desc)
3: select sname,scname,scgrade from s,sc where s.sno=sc.sno and sc.sno in
(select sno from sc group by sno having sum(case when scgrade<60 then 1 else 0 end)>1)
麻烦各位看看这样写可以吗?如果不妥请写出你的见解!谢谢!