File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ -- LeetCode Problem: 181. Employees Earning More Than Their Managers
2+ -- https://leetcode.com/problems/employees-earning-more-than-their-managers/
3+ --
4+ -- Description:
5+ -- The Employee table holds all employees including their managers.
6+ -- Every employee has an Id, and there is also a column for the manager Id.
7+ -- Return the list of employees who earn more than their managers.
8+ --
9+ -- Employee table schema:
10+ -- +----+-------+--------+-----------+
11+ -- | Id | Name | Salary | ManagerId |
12+ -- +----+-------+--------+-----------+
13+ --
14+ -- Example:
15+ -- Input:
16+ -- Employee table:
17+ -- +----+-------+--------+-----------+
18+ -- | Id | Name | Salary | ManagerId |
19+ -- +----+-------+--------+-----------+
20+ -- | 1 | Joe | 70000 | 3 |
21+ -- | 2 | Henry | 80000 | 4 |
22+ -- | 3 | Sam | 60000 | NULL |
23+ -- | 4 | Max | 90000 | NULL |
24+ -- Output:
25+ -- +----------+
26+ -- | Employee |
27+ -- +----------+
28+ -- | Joe |
29+ -- +----------+
30+
31+ -- Solution:
32+ SELECT e .name AS Employee
33+ FROM Employee e
34+ JOIN Employee m ON e .managerId = m .id
35+ WHERE e .salary > m .salary ;
You can’t perform that action at this time.
0 commit comments