sql查询列出各班的平均成绩,最高成绩和最低成绩
有学生表(姓名、学号、性别、班级)、成绩表(课程号、学号、成绩),课程表(课程号、学分、时长、课程名称)。主要是按照班级分那个不会.......
有学生表(姓名、学号、性别、班级)、成绩表(课程号、学号、成绩),课程表(课程号、学分、时长、课程名称)。主要是按照班级分那个不会....
展开
1个回答
2017-08-26
展开全部
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
表连接,分组统计也不会?
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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询