Skip to content

Commit c70dfb1

Browse files
committed
task: #1978
1 parent 5df7460 commit c70dfb1

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Have a good contributing!
6666
- [1729. Find Followers Count](./leetcode/easy/1729.%20Find%20Followers%20Count.sql)
6767
- [1741. Find Total Time Spent by Each Employee](./leetcode/easy/1741.%20Find%20Total%20Time%20Spent%20by%20Each%20Employee.sql)
6868
- [1965. Employees With Missing Information](./leetcode/easy/1965.%20Employees%20With%20Missing%20Information.sql)
69+
- [1978. Employees Whose Manager Left the Company](./leetcode/easy/1978.%20Employees%20Whose%20Manager%20Left%20the%20Company.sql)
6970
- [2356. Number of Unique Subjects Taught by Each Teacher](./leetcode/easy/2356.%20Number%20of%20Unique%20Subjects%20Taught%20by%20Each%20Teacher.sql)
7071
2. [Medium](./leetcode/medium/)
7172
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
Question 1978. Employees Whose Manager Left the Company
3+
Link: https://leetcode.com/problems/employees-whose-manager-left-the-company/description/?envType=study-plan-v2&envId=top-sql-50
4+
5+
Table: Employees
6+
7+
+-------------+----------+
8+
| Column Name | Type |
9+
+-------------+----------+
10+
| employee_id | int |
11+
| name | varchar |
12+
| manager_id | int |
13+
| salary | int |
14+
+-------------+----------+
15+
In SQL, employee_id is the primary key for this table.
16+
This table contains information about the employees, their salary, and the ID of their manager. Some employees do not have a manager (manager_id is null).
17+
18+
19+
Find the IDs of the employees whose salary is strictly less than $30000 and whose manager left the company. When a manager leaves the company, their information is deleted from the Employees table, but the reports still have their manager_id set to the manager that left.
20+
21+
Return the result table ordered by employee_id.
22+
*/
23+
24+
SELECT e1.employee_id
25+
FROM Employees AS e1
26+
WHERE
27+
e1.salary < 30000 AND e1.manager_id NOT IN (
28+
SELECT e2.employee_id
29+
FROM Employees AS e2
30+
)
31+
ORDER BY e1.employee_id ASC

0 commit comments

Comments
 (0)