Skip to content

added solution to lc:1270 #745

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,22 @@ employee_id 是 3, 8 ,9 的职员不会直接或间接的汇报给公司 CEO

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


<!-- tabs:start -->

### **SQL**

```sql

# Write your MySQL query statement below

SELECT e1.employee_id
FROM employees e1
JOIN employees e2
JOIN employees e3
ON e1.manager_id=e2.employee_id
AND e2.manager_id=e3.employee_id
where e3.manager_id=1
AND e1.employee_id!=1;
```

<!-- tabs:end -->
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,23 @@ The employee with employee_id 7 reports their work indirectly to the head of the
The employees with employee_id 3, 8, and 9 do not report their work to the head of the company directly or indirectly.
</pre>

## Solutions
## Solution

<!-- tabs:start -->

### **SQL**

```sql

# Write your MySQL query statement below

SELECT e1.employee_id
FROM employees e1
JOIN employees e2
JOIN employees e3
ON e1.manager_id=e2.employee_id
AND e2.manager_id=e3.employee_id
where e3.manager_id=1
AND e1.employee_id!=1;
```

<!-- tabs:end -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Write your MySQL query statement below
SELECT e1.employee_id
FROM employees e1
JOIN employees e2
JOIN employees e3
ON e1.manager_id=e2.employee_id
AND e2.manager_id=e3.employee_id
where e3.manager_id=1
AND e1.employee_id!=1;