student.stu_id真的没和包含在group by当中吗? --正确的 select temp.班级,temp.语文最高分,temp.语文最低分,temp.语文平均分, temp.数学最高分,temp.数学最低分,temp.数学平均分, temp.英语最高分,temp.英语最低分,temp.英语平均分, temp.化学最高分,temp.化学最低分,temp.化学平均分, temp.物理最高分,temp.物理最低分,temp.物理平均分, temp.总分,temp.平均分,b.maxscore,b.minscore from (select stu_class as 班级, max(sc_Chinese) as 语文最高分,min(sc_Chinese) as 语文最低分,avg(sc_Chinese) as 语文平均分, max(sc_math) as 数学最高分,min(sc_math) as 数学最低分,avg(sc_math) as 数学平均分, max(sc_English) as 英语最高分,min(sc_English) as 英语最低分,avg(sc_English) as 英语平均分, max(sc_chemistry) as 化学最高分,min(sc_chemistry) as 化学最低分,avg(sc_chemistry) as 化学平均分, max(sc_physics) as 物理最高分,min(sc_physics) as 物理最低分,avg(sc_physics) as 物理平均分, sum(sc_Chinese)+sum(sc_math)+sum(sc_English)+sum(sc_chemistry)+sum(sc_physics) 总分, (sum(sc_Chinese)+sum(sc_math)+sum(sc_English)+sum(sc_chemistry)+sum(sc_physics))/count(t.stu_id) 平均分,t.stu_id from score as s left join student as t on s.stu_id = t.stu_id group by stu_class) temp left join
(select a.stu_id,max(a.sumscore) maxscore,min(a.sumscore) minscore from score right join ( select student.stu_id,sum(sc_Chinese)+sum(sc_math)+sum(sc_English)+sum(sc_chemistry)+sum(sc_physics) sumscore from score left join student on student.stu_id=score.stu_id group by student.stu_id) a on score.stu_id = a.stu_id group by a.stu_id) b on temp.stu_id = b.stu_id;