2. 查询平均成绩大于60分的同学的学号和平均成绩
SELECT
sid,
avg( score ) AS '平均成绩'
FROM
sc
GROUP BY
SId
HAVING
AVG( score )> 60
结果:
变式:2.查询平均成绩大于等于 60 分的同学的学生编号和学生姓名和平均成绩
SELECT
sc.sid,
a.sname,
avg( score ) AS '平均成绩'
FROM
sc
LEFT JOIN student AS a ON sc.SId = a.sid
GROUP BY
SId
HAVING
AVG( score )> 60
结果