Skip to content

Commit b923fe9

Browse files
authored
feat: add sql solution to lc problem: No.1270 (doocs#745)
No.1270. All People Report to the Given Manager
1 parent 0092368 commit b923fe9

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

solution/1200-1299/1270.All People Report to the Given Manager/README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,22 @@ employee_id 是 3, 8 ,9 的职员不会直接或间接的汇报给公司 CEO
6767

6868
<!-- 这里可写通用的实现逻辑 -->
6969

70+
7071
<!-- tabs:start -->
7172

7273
### **SQL**
7374

7475
```sql
75-
76+
# Write your MySQL query statement below
77+
78+
SELECT e1.employee_id
79+
FROM employees e1
80+
JOIN employees e2
81+
JOIN employees e3
82+
ON e1.manager_id=e2.employee_id
83+
AND e2.manager_id=e3.employee_id
84+
where e3.manager_id=1
85+
AND e1.employee_id!=1;
7686
```
7787

7888
<!-- tabs:end -->

solution/1200-1299/1270.All People Report to the Given Manager/README_EN.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,23 @@ The employee with employee_id 7 reports their work indirectly to the head of the
6464
The employees with employee_id 3, 8, and 9 do not report their work to the head of the company directly or indirectly.
6565
</pre>
6666

67-
## Solutions
67+
## Solution
6868

6969
<!-- tabs:start -->
7070

7171
### **SQL**
7272

7373
```sql
74-
74+
# Write your MySQL query statement below
75+
76+
SELECT e1.employee_id
77+
FROM employees e1
78+
JOIN employees e2
79+
JOIN employees e3
80+
ON e1.manager_id=e2.employee_id
81+
AND e2.manager_id=e3.employee_id
82+
where e3.manager_id=1
83+
AND e1.employee_id!=1;
7584
```
7685

7786
<!-- tabs:end -->
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Write your MySQL query statement below
2+
SELECT e1.employee_id
3+
FROM employees e1
4+
JOIN employees e2
5+
JOIN employees e3
6+
ON e1.manager_id=e2.employee_id
7+
AND e2.manager_id=e3.employee_id
8+
where e3.manager_id=1
9+
AND e1.employee_id!=1;

0 commit comments

Comments
 (0)