转自:https://blog.csdn.net/zqmy_/article/details/84929955
学生表student
班级表class
课程表subject
成绩表score
查询所有学生各科成绩按照总成绩降序排列。
1.获取指定课程的学生成绩
select sc.stu_id,sc.score from score sc where sc.subject_id=1001
2.获取学生各科目的总成绩
select sc.stu_id,sum(sc.score) sumscore from score sc group by sc.stu_id
select sum(成绩) as 总分
from 成绩表
group by 学生id
order by 总分 desc