leetCode/sql/超过经理收入的员工.sql

31 lines
849 B
MySQL
Raw Normal View History

2020-11-21 13:03:04 +00:00
/**
2020-02-23 14:02:58 +00:00
Employee Id Id
```
+----+-------+--------+-----------+
| Id | Name | Salary | ManagerId |
+----+-------+--------+-----------+
| 1 | Joe | 70000 | 3 |
| 2 | Henry | 80000 | 4 |
| 3 | Sam | 60000 | NULL |
| 4 | Max | 90000 | NULL |
+----+-------+--------+-----------+
```
Employee SQL Joe
```
+----------+
| Employee |
+----------+
| Joe |
+----------+
```
2020-11-21 13:03:04 +00:00
**/
2020-02-23 14:02:58 +00:00
select a.Name as Employee
from Employee a, (select Salary,Id from Employee) b
where a.ManagerId=b.Id and a.Salary > b.Salary
2020-11-21 13:03:04 +00:00