You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -885,6 +885,7 @@ _If you like this project, please leave me a star._ ★
885
885
|1308|[Running Total for Different Genders](https://leetcode.com/problems/running-total-for-different-genders/)|[Solution](../master/database/_1308.sql)|| Medium |
886
886
|1294|[Weather Type in Each Country](https://leetcode.com/problems/weather-type-in-each-country/)|[Solution](../master/database/_1294.sql)|| Easy |
887
887
|1280|[Students and Examinations](https://leetcode.com/problems/students-and-examinations/)|[Solution](../master/database/_1280.sql)|[:tv:](https://www.youtube.com/watch?v=ThbkV4Fs7iE)| Easy |
888
+
|1270|[All People Report to the Given Manager](https://leetcode.com/problems/all-people-report-to-the-given-manager/)|[Solution](../master/database/_1270.sql)|| Medium |
--Each row of this table indicates that the employee with ID employee_id and name employee_name reports his work to his/her direct manager with manager_id
14
+
--The head of the company is the employee with employee_id = 1.
15
+
--
16
+
--
17
+
--Write an SQL query to find employee_id of all employees that directly or indirectly report their work to the head of the company.
18
+
--
19
+
--The indirect relation between managers will not exceed 3 managers as the company is small.
20
+
--
21
+
--Return result table in any order without duplicates.
22
+
--
23
+
--The query result format is in the following example:
24
+
--
25
+
--Employees table:
26
+
--+-------------+---------------+------------+
27
+
--| employee_id | employee_name | manager_id |
28
+
--+-------------+---------------+------------+
29
+
--| 1 | Boss | 1 |
30
+
--| 3 | Alice | 3 |
31
+
--| 2 | Bob | 1 |
32
+
--| 4 | Daniel | 2 |
33
+
--| 7 | Luis | 4 |
34
+
--| 8 | Jhon | 3 |
35
+
--| 9 | Angela | 8 |
36
+
--| 77 | Robert | 1 |
37
+
--+-------------+---------------+------------+
38
+
--
39
+
--Result table:
40
+
--+-------------+
41
+
--| employee_id |
42
+
--+-------------+
43
+
--| 2 |
44
+
--| 77 |
45
+
--| 4 |
46
+
--| 7 |
47
+
--+-------------+
48
+
--
49
+
--The head of the company is the employee with employee_id 1.
50
+
--The employees with employee_id 2 and 77 report their work directly to the head of the company.
51
+
--The employee with employee_id 4 report his work indirectly to the head of the company 4 --> 2 --> 1.
52
+
--The employee with employee_id 7 report his work indirectly to the head of the company 7 --> 4 --> 2 --> 1.
53
+
--The employees with employee_id 3, 8 and 9 don't report their work to head of company directly or indirectly.
0 commit comments