Skip to content

Commit 07096cc

Browse files
authored
feat: add sql solution to lc problem: No.601 (#4807)
1 parent 82a55ad commit 07096cc

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

solution/0600-0699/0601.Human Traffic of Stadium/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,38 @@ ORDER BY 1;
105105

106106
<!-- solution:end -->
107107

108+
<!-- solution:start -->
109+
110+
### 方法二
111+
112+
<!-- tabs:start -->
113+
114+
#### MySQL
115+
116+
```sql
117+
# Write your MySQL query statement below
118+
WITH
119+
Consecutive AS (
120+
SELECT
121+
*,
122+
id - ROW_NUMBER() OVER () AS id_diff
123+
FROM Stadium
124+
WHERE people >= 100
125+
)
126+
SELECT id, visit_date, people
127+
FROM Consecutive
128+
WHERE
129+
id_diff IN (
130+
SELECT id_diff
131+
FROM Consecutive
132+
GROUP BY id_diff
133+
HAVING COUNT(*) > 2
134+
)
135+
ORDER BY visit_date;
136+
```
137+
138+
<!-- tabs:end -->
139+
140+
<!-- solution:end -->
141+
108142
<!-- problem:end -->

solution/0600-0699/0601.Human Traffic of Stadium/README_EN.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,38 @@ ORDER BY 1;
104104

105105
<!-- solution:end -->
106106

107+
<!-- solution:start -->
108+
109+
### Solution 2
110+
111+
<!-- tabs:start -->
112+
113+
#### MySQL
114+
115+
```sql
116+
# Write your MySQL query statement below
117+
WITH
118+
Consecutive AS (
119+
SELECT
120+
*,
121+
id - ROW_NUMBER() OVER () AS id_diff
122+
FROM Stadium
123+
WHERE people >= 100
124+
)
125+
SELECT id, visit_date, people
126+
FROM Consecutive
127+
WHERE
128+
id_diff IN (
129+
SELECT id_diff
130+
FROM Consecutive
131+
GROUP BY id_diff
132+
HAVING COUNT(*) > 2
133+
)
134+
ORDER BY visit_date;
135+
```
136+
137+
<!-- tabs:end -->
138+
139+
<!-- solution:end -->
140+
107141
<!-- problem:end -->
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Write your MySQL query statement below
2+
WITH
3+
Consecutive AS (
4+
SELECT
5+
*,
6+
id - ROW_NUMBER() OVER () AS id_diff
7+
FROM Stadium
8+
WHERE people >= 100
9+
)
10+
SELECT id, visit_date, people
11+
FROM Consecutive
12+
WHERE
13+
id_diff IN (
14+
SELECT id_diff
15+
FROM Consecutive
16+
GROUP BY id_diff
17+
HAVING COUNT(*) > 2
18+
)
19+
ORDER BY visit_date;

0 commit comments

Comments
 (0)