当前位置:
首页 >
【MySQL】按平均成绩从高到低显示所有学生的所有课程的成绩以及平均成绩
发布时间:2025/3/21
54
豆豆
生活随笔
收集整理的这篇文章主要介绍了
【MySQL】按平均成绩从高到低显示所有学生的所有课程的成绩以及平均成绩
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
思路:
1、先查找所有学生的平均成绩
2、再查找所有学生的所有课程的成绩
select st.sid,st.sname,co.cname,sc.degree from score sc,course co,student st where sc.cid=co.cid and sc.sid=st.sid3、四表联查,并按照平均成绩从高到低排序
select st.sid,st.sname,co.cname,sc.degree,avgscore from score sc,course co,student st, (select sid,avg(degree) as avgscore from score GROUP BY sid) as nb where sc.cid=co.cid and sc.sid=st.sid and nb.sid=st.sid order BY avgscore desc总结
以上是生活随笔为你收集整理的【MySQL】按平均成绩从高到低显示所有学生的所有课程的成绩以及平均成绩的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: Shell脚本之条件判断
- 下一篇: 【django】配置数据库(mysql)