Skip to content

Commit f37139f

Browse files
committed
task: #1965
1 parent 5f54292 commit f37139f

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Have a good contributing!
6060
- [1693. Daily Leads and Partners](./leetcode/easy/1693.%20Daily%20Leads%20and%20Partners.sql)
6161
- [1729. Find Followers Count](./leetcode/easy/1729.%20Find%20Followers%20Count.sql)
6262
- [1741. Find Total Time Spent by Each Employee](./leetcode/easy/1741.%20Find%20Total%20Time%20Spent%20by%20Each%20Employee.sql)
63+
- [1965. Employees With Missing Information](./leetcode/easy/1965.%20Employees%20With%20Missing%20Information.sql)
6364
2. [Medium](./leetcode/medium/)
6465
- [176. Second Highest Salary](./leetcode/medium/176.%20Second%20Highest%20Salary.sql)
6566
- [184. Department Highest Salary](./leetcode/medium/184.%20Department%20Highest%20Salary.sql)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
Question 1965. Employees With Missing Information
3+
Link: https://leetcode.com/problems/employees-with-missing-information/description/
4+
5+
Table: Employees
6+
7+
+-------------+---------+
8+
| Column Name | Type |
9+
+-------------+---------+
10+
| employee_id | int |
11+
| name | varchar |
12+
+-------------+---------+
13+
employee_id is the column with unique values for this table.
14+
Each row of this table indicates the name of the employee whose ID is employee_id.
15+
16+
17+
Table: Salaries
18+
19+
+-------------+---------+
20+
| Column Name | Type |
21+
+-------------+---------+
22+
| employee_id | int |
23+
| salary | int |
24+
+-------------+---------+
25+
employee_id is the column with unique values for this table.
26+
Each row of this table indicates the salary of the employee whose ID is employee_id.
27+
28+
29+
Write a solution to report the IDs of all the employees with missing information. The information of an employee is missing if:
30+
31+
The employee's name is missing, or
32+
The employee's salary is missing.
33+
Return the result table ordered by employee_id in ascending order.
34+
*/
35+
36+
WITH all_employees AS (
37+
SELECT employee_id
38+
FROM Employees
39+
UNION
40+
SELECT employee_id
41+
FROM Salaries
42+
)
43+
44+
SELECT a.employee_id
45+
FROM all_employees AS a
46+
LEFT JOIN
47+
Employees AS e
48+
ON a.employee_id = e.employee_id
49+
LEFT JOIN
50+
Salaries AS s
51+
ON a.employee_id = s.employee_id
52+
WHERE e.name IS NULL OR s.salary IS NULL
53+
ORDER BY a.employee_id ASC

0 commit comments

Comments
 (0)