Skip to content

Commit 8c7a925

Browse files
authored
add solution to lc problem: No.601
1 parent 53c9048 commit 8c7a925

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-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 -->
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)