sql查询列出各班的平均成绩,最高成绩和最低成绩
表连接,分组统计也不会?
SELECT S.ClassCode AS [班级代码]
,C.ClassName AS [班级名称]
,Avg(Score) AS [平均分]
,Max(Score) AS [最高分]
,Min(Score) AS [最低分]
FROM Scores S
JOIN Classes C ON C.Code = S.ClassCode
WHERE S.CourseCode IN (
SELECT CourseCode
FROM Courses
WHERE Name = '高等数学'
)
GROUP BY S.ClassCode
ORDER BY S.ClassCode