阅读量:0
在MySQL中,可以使用聚合函数和GROUP BY子句对成绩(score)进行统计分析。以下是一些常见的统计分析方法:
- 计算平均分:
SELECT AVG(score) as average_score FROM your_table;
- 计算最高分和最低分:
SELECT MIN(score) as min_score, MAX(score) as max_score FROM your_table;
- 计算总分:
SELECT SUM(score) as total_score FROM your_table;
- 按照分数范围进行分组统计:
SELECT CASE WHEN score BETWEEN 0 AND 59 THEN '0-59' WHEN score BETWEEN 60 AND 79 THEN '60-79' WHEN score BETWEEN 80 AND 99 THEN '80-99' ELSE '100' END as score_range, COUNT(*) as count FROM your_table GROUP BY score_range;
- 按照某个字段(例如:class)进行分组统计:
SELECT class, AVG(score) as average_score, MIN(score) as min_score, MAX(score) as max_score FROM your_table GROUP BY class;
请将your_table
替换为你的表名,并根据需要调整查询语句。