– 查询不同老师所教不同课程平均分从高到低显示
SELECT
t.t_id,
t.t_name,
c.c_name,
AVG(sc.s_score)
FROM teacher t
LEFT JOIN course c ON c.t_id=t.t_id
LEFT JOIN score sc ON sc.c_id =c.c_id
GROUP BY t.t_id
ORDER BY AVG(sc.s_score) DESC
– 查询不同老师所教不同课程平均分从高到低显示
SELECT
t.t_id,
t.t_name,
c.c_name,
AVG(sc.s_score)
FROM teacher t
LEFT JOIN course c ON c.t_id=t.t_id
LEFT JOIN score sc ON sc.c_id =c.c_id
GROUP BY t.t_id
ORDER BY AVG(sc.s_score) DESC