根据班级来 算出每个班级的的分数段的sql语句分列写法
select ClassID,
SUM(CASE WHEN score >= 60 THEN 1 ELSE 0 END) AS Score1,
SUM(CASE WHEN score >= 80 THEN 1 ELSE 0 END) AS Score2,
SUM(CASE WHEN score = 100 THEN 1 ELSE 0 END) AS Score3
FROM Student
group by ClassID
select ClassID,
SUM(CASE WHEN score >= 60 THEN 1 ELSE 0 END) AS Score1,
SUM(CASE WHEN score >= 80 THEN 1 ELSE 0 END) AS Score2,
SUM(CASE WHEN score = 100 THEN 1 ELSE 0 END) AS Score3
FROM Student
group by ClassID