题目地址:https://leetcode.com/problems/employees-earning-more-than-their-managers/
题解:找到上司的薪水直接比较,通过两个select实现。
select Name as Employee
from Employee
where Salary > (
select Salary
from Employee as e
where e.id=Employee.ManagerId
);
或者另一种写法:
select t1.Name Employee
from Employee t1, Employee t2
where t1.ManagerId = t2.Id and t1.Salary > t2.Salary