Mysql案例5:取得平均薪资最高的部门的部门名称
时间:2021-07-01 10:21:17
帮助过:10人阅读
e.departmentid,d.name,AVG(e.salary) avgsal
FROM
employee e
INNER JOIN
department d
ON
e.departmentid =d.id
GROUP BY
e.departmentid,d.`name`
HAVING
avgsal = (
SELECT
MAX(t.avgsal) maxsal
FROM (
SELECT departmentid,
AVG(salary) avgsal
FROM employee
GROUP BY departmentid) t
)
结果图:
Mysql案例5:取得平均薪资最高的部门的部门名称
标签:员工 mys 9.png sel 语句 nbsp mic XSA style