SQL语句多表查询:取每位同学各门课的平均成绩,显示成绩前三名的同学的姓名和平均成绩

阅读 82

2022-02-05

MariaDB [hellodb]> select name,avg(score) from students as st,scores as sc,courses as co where st.stuid=sc.stuid and sc.courseid=co.courseid group by st.name order by avg(score) desc limit 3;
+-------------+------------+
| name        | avg(score) |
+-------------+------------+
| Shi Qing    |    96.0000 |
| Shi Zhongyu |    85.0000 |
| Xi Ren      |    84.5000 |
+-------------+------------+

精彩评论(0)

0 0 举报