标签: postgresql
选择Fname,Lname,薪水,Dname
从业人员,部门
工资在哪里> =
(选择AVG(工资)
从雇员);
按名称分组
Db小提琴链接:
https://www.db-fiddle.com/f/xhEj2sAgdTMABBkCtJvmoC/0#&togetherjs=z3CKywAccH
答案 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