Mysql案例6_求平均薪资的等级最低的部门的部门名称
时间:2021-07-01 10:21:17
帮助过:25人阅读
t.*,s.grade
FROM
(
SELECT
e.departmentid, d.`name`,AVG(salary) avgsal
FROM
employee e
INNER JOIN
department d
on
e.departmentid=d.id
GROUP BY
e.departmentid,d.`name` ) t
INNER JOIN
salgrade s
ON
t.avgsal BETWEEN s.losal
AND s.hisal
WHERE
grade = (
SELECT
MIN(t.grade) mingra
FROM (
SELECT
t.*,s.grade
FROM
(
SELECT
e.departmentid, d.`name`,AVG(salary) avgsal
FROM
employee e
INNER JOIN
department d
on
e.departmentid=d.id
GROUP BY
e.departmentid,d.`name`) t
INNER JOIN
salgrade s
ON
t.avgsal BETWEEN s.losal
AND s.hisal) t
)
Mysql案例6_求平均薪资的等级最低的部门的部门名称
标签:code info .com span 部门 img osal 图片 pre