我正在编写查询以查找分数在 1-50 和 50-70 和 70-100 之间的学生人数我试图解决它,但我所做的只是检索分数在 1-50 之间的学生,我需要检索其他值(50-70 和 70-100 之间)
;with StudentMarks as
(
SELECT Users.UserID,classes.Name Class, courses.Name AS Course, Sum(UserExams.StudentMark) Tot
FROM ClassCourses INNER JOIN classes ON ClassCourses.ClassID = classes.ClassID
INNER JOIN courses ON ClassCourses.CourseID = courses.CourseID
INNER JOIN Exams ON ClassCourses.ClassID = Exams.ClassID AND ClassCourses.CourseID = Exams.CourseID
INNER JOIN SectionsClasses ON classes.ClassID = SectionsClasses.ClassID
INNER JOIN UserExams ON Exams.ExamID = UserExams.ExamID
INNER JOIN Users ON SectionsClasses.SectionID = Users.SectionID AND SectionsClasses.ClassID = Users.ClassID AND UserExams.UserID = Users.UserID
Group by Users.UserID, classes.Name ,courses.Name
)
SELECT Class,Course,
count(UserID)'1-50'
from StudentMarks
where tot between 1 and 50
Group by Class,Course
有人可以帮忙吗?