Skip to content

Commit 4fb7936

Browse files
committed
feat: update solutions to lc problems: No.0175,0570
* No.0175.Combine Two Tables * No.0570.Managers with at Least 5 Direct Reports
1 parent 334aaf8 commit 4fb7936

File tree

6 files changed

+79
-21
lines changed

6 files changed

+79
-21
lines changed

solution/0100-0199/0175.Combine Two Tables/README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,22 @@ addressId = 1 包含了 personId = 2 的地址信息。</pre>
7878

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

81-
左连接
81+
**方法一:左连接**
8282

8383
<!-- tabs:start -->
8484

8585
### **SQL**
8686

8787
```sql
88-
SELECT p.FirstName,
89-
p.LastName,
90-
a.City,
91-
a.State
92-
FROM Person p
93-
LEFT JOIN Address a ON p.PersonId = a.PersonId;
88+
# Write your MySQL query statement below
89+
select
90+
firstName,
91+
lastName,
92+
city,
93+
state
94+
from
95+
Person p
96+
left join Address a on p.personId = a.personId
9497
```
9598

9699
<!-- tabs:end -->

solution/0100-0199/0175.Combine Two Tables/README_EN.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,15 @@ addressId = 1 contains information about the address of personId = 2.
8181
### **SQL**
8282

8383
```sql
84-
SELECT p.FirstName,
85-
p.LastName,
86-
a.City,
87-
a.State
88-
FROM Person p
89-
LEFT JOIN Address a ON p.PersonId = a.PersonId;
84+
# Write your MySQL query statement below
85+
select
86+
firstName,
87+
lastName,
88+
city,
89+
state
90+
from
91+
Person p
92+
left join Address a on p.personId = a.personId
9093
```
9194

9295
<!-- tabs:end -->
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
SELECT p.FirstName,
2-
p.LastName,
3-
a.City,
4-
a.State
5-
FROM Person p
6-
LEFT JOIN Address a ON p.PersonId = a.PersonId;
1+
# Write your MySQL query statement below
2+
select
3+
firstName,
4+
lastName,
5+
city,
6+
state
7+
from
8+
Person p
9+
left join Address a on p.personId = a.personId

solution/0500-0599/0570.Managers with at Least 5 Direct Reports/README.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,23 @@ Employee 表:
6464
### **SQL**
6565

6666
```sql
67-
67+
# Write your MySQL query statement below
68+
select
69+
name
70+
from
71+
Employee e1
72+
join (
73+
select
74+
managerId
75+
from
76+
Employee
77+
where
78+
managerId is not null
79+
group by
80+
managerId
81+
having
82+
count(1) >= 5
83+
) e2 on e1.id = e2.managerId;
6884
```
6985

7086
<!-- tabs:end -->

solution/0500-0599/0570.Managers with at Least 5 Direct Reports/README_EN.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,23 @@ Employee table:
6060
### **SQL**
6161

6262
```sql
63-
63+
# Write your MySQL query statement below
64+
select
65+
name
66+
from
67+
Employee e1
68+
join (
69+
select
70+
managerId
71+
from
72+
Employee
73+
where
74+
managerId is not null
75+
group by
76+
managerId
77+
having
78+
count(1) >= 5
79+
) e2 on e1.id = e2.managerId;
6480
```
6581

6682
<!-- tabs:end -->
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Write your MySQL query statement below
2+
select
3+
name
4+
from
5+
Employee e1
6+
join (
7+
select
8+
managerId
9+
from
10+
Employee
11+
where
12+
managerId is not null
13+
group by
14+
managerId
15+
having
16+
count(1) >= 5
17+
) e2 on e1.id = e2.managerId;

0 commit comments

Comments
 (0)