Catalogue
- Directory
- Topic
- Ideas
- AC SQL
Topics
The Employee table holds all employees including their managers. Every employee has an ID, and there is also a column for the manager ID.
Id |
Name |
Salary |
ManagerID |
1 |
Joe |
70000 |
3 |
2 |
Henry |
80000 |
4 |
3 |
Sam |
60000 |
Null |
4 |
Max |
90000 |
Null |
Given The Employee table, write a SQL query, finds out employees who earn more than their managers. For the above table, Joe was the only employee of the WHO earns more than his manager.
Ideas
The title is to find the employee's name from the employee table whose employee's salary is greater than the manager's salary.
The implementation scheme is also inline with MySQL, directly on AC SQL.
AC SQL
select e1.Name from Employee as e1 inner join Employee as e2 on e1.ManagerId = e2.Id and e1.Salary > e2.Salary;
[Leetcode] Employees earning more Than their Managers, problem solving report