轉自: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