三个table:student,course,score
题目是:查询考了英语且分数超过所有考英语同学平均分的学生姓名和年龄
我的:
select sname,age from student
inner join score
on student.sno=score.sno
inner join course
on score.cno=course.cno
where cname='英语' and score>(select avg(score) from score )
group by sname,age
与正确的:
select sname from student
where sno in(
select sno from score
where cno = (
select cno from course
where cname='英语'
) and score>(
select a v g(score) from score
where cno = (
select cno from course
where cname='英语'
)
)
)
为什么我的出不来正确答案。。我看理解也挺正确的啊~~~
SQL
------解决方案--------------------
select sname,age from student
inner join score
on student.sno=score.sno
inner join course
on score.cno=course.cno
where cname='英语' and score>(select avg(score) from score where cname='英语')
你的平均分处没指定是英语成绩啊