抢分就是这么简单。
select avg(score),grade.cno
from course,grade
where course.cno=grade.cno
and grade.cno in
(select cno
from course
where teacher= '王% ');
'grade.cno ' 在选择列表中无效,因为该列未包含在聚合函数中,并且没有 GROUP BY 子句。
查询王老师讲的每门课的学生平均成绩,输出课程号和平均成绩。
------解决方案--------------------select avg(score),grade.cno
from course,grade
where course.cno=grade.cno
and grade.cno in
(select cno
from course
where teacher= '王% ')
group by grade.cno