Skip to content

Commit 93333f6

Browse files
committed
Sync LeetCode submission Runtime - 1469 ms (9.17%), Memory - 0B (100.00%)
1 parent 1c3eee7 commit 93333f6

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<p>Table: <code>Employee</code></p>
2+
3+
<pre>
4+
+-------------+---------+
5+
| Column Name | Type |
6+
+-------------+---------+
7+
| id | int |
8+
| name | varchar |
9+
| salary | int |
10+
| managerId | int |
11+
+-------------+---------+
12+
id is the primary key (column with unique values) for this table.
13+
Each row of this table indicates the ID of an employee, their name, salary, and the ID of their manager.
14+
</pre>
15+
16+
<p>&nbsp;</p>
17+
18+
<p>Write a solution&nbsp;to find the employees who earn more than their managers.</p>
19+
20+
<p>Return the result table in <strong>any order</strong>.</p>
21+
22+
<p>The result format is in the following example.</p>
23+
24+
<p>&nbsp;</p>
25+
<p><strong class="example">Example 1:</strong></p>
26+
27+
<pre>
28+
<strong>Input:</strong>
29+
Employee table:
30+
+----+-------+--------+-----------+
31+
| id | name | salary | managerId |
32+
+----+-------+--------+-----------+
33+
| 1 | Joe | 70000 | 3 |
34+
| 2 | Henry | 80000 | 4 |
35+
| 3 | Sam | 60000 | Null |
36+
| 4 | Max | 90000 | Null |
37+
+----+-------+--------+-----------+
38+
<strong>Output:</strong>
39+
+----------+
40+
| Employee |
41+
+----------+
42+
| Joe |
43+
+----------+
44+
<strong>Explanation:</strong> Joe is the only employee who earns more than his manager.
45+
</pre>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Write your MySQL query statement below
2+
SELECT name AS Employee FROM Employee
3+
WHERE Employee.salary > (
4+
SELECT Salary FROM Employee AS Employee2
5+
WHERE Employee2.id = Employee.managerId
6+
);

0 commit comments

Comments
 (0)