,
1.
这是一张班级的成绩表,想统计出每个成绩段的数据,mysql的sql语句该怎么写呢。
2条回答 默认 最新
GrowingDarker 2015-12-01 02:44关注select '60分以下' type, count(*) from student s where s.score < 60 union all select '60分以上70分以下' type,count(*) from student s where s.score < 70 and s.score > 60 union all select '70分以上80分以下' type,count(*) from student s where s.score < 80 and s.score > 70 union all select '80分以上90分以下' type,count(*) from student s where s.score < 90 and s.score > 80 union all select '90分以上' type,count(*) from student s where s.score > 90; 结果 +------------------+----------+ | type | count(*) | +------------------+----------+ | 60分以下 | 1 | | 60分以上70分以下 | 1 | | 70分以上80分以下 | 2 | | 80分以上90分以下 | 1 | | 90分以上 | 3 | +------------------+----------+本回答被题主选为最佳回答 , 对您是否有帮助呢?评论 打赏 举报解决 2无用