列出收入大于或等于同一部门的雇员的平均工资的雇员

时间:2019-01-30 17:51:57

标签: postgresql

选择Fname,Lname,薪水,Dname

从业人员,部门

工资在哪里> =

(选择AVG(工资)

从雇员);

按名称分组

Db小提琴链接:

https://www.db-fiddle.com/f/xhEj2sAgdTMABBkCtJvmoC/0#&togetherjs=z3CKywAccH

1 个答案:

答案 0 :(得分:0)

SELECT Fname, Lname, Salary, Dname
FROM EMPLOYEE AS E1
LEFT JOIN DEPARTMENT AS D ON Dnumber = Dno
WHERE Salary >= (SELECT AVG(Salary) FROM EMPLOYEE AS E2 WHERE E2.Dno = E1.Dno)
ORDER BY Dname, Fname, Lname

enter image description here