学生表 stu
班级表 class
成绩表 grade
现要求查询每个班的course1课程的平均成绩,要求字段:班级id、班级名称、course1 的平均分
select c.id classId ,c.name className ,avg(g.scope) avgScope
from stu s join grade g on s.gid=g.id join class c on s.cid=c.id
where g.course='course1'
group by c.id
或
select c.id classId ,c.name className ,avg(g.scope) avgScope
from stu s ,class c, grade g
where g.id=s.gid and s.cid=c.id and g.course='course1'
group by c.id