我想要找回薪水比经理少的员工姓名。
例如:
Employee_Lastname:WARX
Employee_Firstname:CYNTHIA
MANAGER_NANE:SMITH
Warx Cythnia的经理是Manager_ID = 7369谁是Smith John,因为Smith的Employee_ID = 7369。此外,Warx的薪水小于史密斯(1575 <8900)
SELECT a.Employee_LastName, a.Employee_Firstname
FROM EMPLOYEE a
LEFT JOIN EMPLOYEE b
ON a.Manager_ID = b.Employee_ID AND a.Employee_Salary > b.Employee_Salary
答案 0 :(得分:3)
这与您之前的问题略有修改,
SELECT a.Employee_LastName,
a.Employee_FirstName,
b.Employee_LastName AS MANAGER_LASTNAME
FROM EmpTable a
LEFT JOIN EmpTable b
ON a.Manager_ID = b.Employee_ID
WHERE a.employee_salary < b.employee_salary
答案 1 :(得分:1)
尝试:
SELECT e1.employee_id, e1.lastname, e1.firstname
FROM employee e1 INNER JOIN employee e2 ON e1.manager_id = e2.employee_id
WHERE e1.employee_salary < e2.employee_salary
答案 2 :(得分:1)
Select Employee_Firstname
From Employee worker
INNER JOIN Employee manager ON worker.Employee_ID = manager.Manager_ID
AND worker.Employee_Salary < manager.Employee_Salary