【MySQL】按平均成绩从高到低显示所有学生的所有课程的成绩以及平均成绩
生活随笔
收集整理的這篇文章主要介紹了
【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脚本之条件判断
- 下一篇: Shell编程之for循环