查询至少选修了两门课程并且平均成绩大于或等于75分的学生的学号、姓名、成绩和所在班级。写出相应的SQL语句
select S.studentNo,studentName,Score,className
from Student S join Score on S.studentNo=Score.studentNo
join Course on Course.courseNo=Score.courseNo
join Class on S.classNo=Class.classNo
join (select COUNT(courseName) num,student.studentNo/*连接选棵数*/
from Student join Score on Student.studentNo=Score.studentNo
join Course on Score.courseNo=Course.courseNo group by student.studentNo)
as U on U.studentNo=S.studentNo
join (select AVG(score) gg ,courseNo /*连接各课程的平均分*/
from Score join student H on Score.studentNo=H.studentNo
group by courseNo) G on G.courseNo=Course.courseNo
where num>=2 and gg>=75 /*选择选课数大于等于2,平均分大于75的*/
Ps:COUNT 和 AVG 得放在子查询里才可以