From ba7390d00cdcbaa486352c1f7f69b18f53e84bc8 Mon Sep 17 00:00:00 2001 From: Huu Hung Nguyen <79944868+hhnguyen-20@users.noreply.github.com> Date: Tue, 28 Oct 2025 22:55:24 -0700 Subject: [PATCH 1/4] Add MySQL query solution to README_EN.md Added MySQL solution for human traffic analysis in stadium. --- .../README_EN.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/solution/0600-0699/0601.Human Traffic of Stadium/README_EN.md b/solution/0600-0699/0601.Human Traffic of Stadium/README_EN.md index dc36ad8762022..d0b83e40bc5cc 100644 --- a/solution/0600-0699/0601.Human Traffic of Stadium/README_EN.md +++ b/solution/0600-0699/0601.Human Traffic of Stadium/README_EN.md @@ -104,4 +104,35 @@ ORDER BY 1; + + +### Solution 2 + + + +#### MySQL + +```sql +# Write your MySQL query statement below +WITH Consecutive AS ( + SELECT + *, + id - ROW_NUMBER() OVER() AS id_diff + FROM Stadium + WHERE people >= 100 +) +SELECT id, visit_date, people +FROM Consecutive +WHERE id_diff IN ( + SELECT id_diff + FROM Consecutive + GROUP BY id_diff HAVING COUNT(*) > 2 +) +ORDER BY visit_date; +``` + + + + + From 53c90482a049afc1b220075ee86f320819b443ff Mon Sep 17 00:00:00 2001 From: hhnguyen-20 <79944868+hhnguyen-20@users.noreply.github.com> Date: Wed, 29 Oct 2025 05:56:43 +0000 Subject: [PATCH 2/4] style: format code and docs with prettier --- .../README_EN.md | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/solution/0600-0699/0601.Human Traffic of Stadium/README_EN.md b/solution/0600-0699/0601.Human Traffic of Stadium/README_EN.md index d0b83e40bc5cc..caa75168f2aaa 100644 --- a/solution/0600-0699/0601.Human Traffic of Stadium/README_EN.md +++ b/solution/0600-0699/0601.Human Traffic of Stadium/README_EN.md @@ -114,20 +114,23 @@ ORDER BY 1; ```sql # Write your MySQL query statement below -WITH Consecutive AS ( - SELECT - *, - id - ROW_NUMBER() OVER() AS id_diff - FROM Stadium - WHERE people >= 100 -) +WITH + Consecutive AS ( + SELECT + *, + id - ROW_NUMBER() OVER () AS id_diff + FROM Stadium + WHERE people >= 100 + ) SELECT id, visit_date, people FROM Consecutive -WHERE id_diff IN ( - SELECT id_diff - FROM Consecutive - GROUP BY id_diff HAVING COUNT(*) > 2 -) +WHERE + id_diff IN ( + SELECT id_diff + FROM Consecutive + GROUP BY id_diff + HAVING COUNT(*) > 2 + ) ORDER BY visit_date; ``` From 8c7a9251840e950e2170cbe634c96a4df662c6e6 Mon Sep 17 00:00:00 2001 From: Huu Hung Nguyen <79944868+hhnguyen-20@users.noreply.github.com> Date: Wed, 29 Oct 2025 08:42:57 -0700 Subject: [PATCH 3/4] add solution to lc problem: No.601 --- .../0601.Human Traffic of Stadium/README.md | 34 +++++++++++++++++++ .../Solution2.sql | 19 +++++++++++ 2 files changed, 53 insertions(+) create mode 100644 solution/0600-0699/0601.Human Traffic of Stadium/Solution2.sql diff --git a/solution/0600-0699/0601.Human Traffic of Stadium/README.md b/solution/0600-0699/0601.Human Traffic of Stadium/README.md index a953a7078da04..433f4914d8a49 100644 --- a/solution/0600-0699/0601.Human Traffic of Stadium/README.md +++ b/solution/0600-0699/0601.Human Traffic of Stadium/README.md @@ -105,4 +105,38 @@ ORDER BY 1; + + +### 方法二 + + + +#### MySQL + +```sql +# Write your MySQL query statement below +WITH + Consecutive AS ( + SELECT + *, + id - ROW_NUMBER() OVER () AS id_diff + FROM Stadium + WHERE people >= 100 + ) +SELECT id, visit_date, people +FROM Consecutive +WHERE + id_diff IN ( + SELECT id_diff + FROM Consecutive + GROUP BY id_diff + HAVING COUNT(*) > 2 + ) +ORDER BY visit_date; +``` + + + + + diff --git a/solution/0600-0699/0601.Human Traffic of Stadium/Solution2.sql b/solution/0600-0699/0601.Human Traffic of Stadium/Solution2.sql new file mode 100644 index 0000000000000..81a63fc92b14c --- /dev/null +++ b/solution/0600-0699/0601.Human Traffic of Stadium/Solution2.sql @@ -0,0 +1,19 @@ +# Write your MySQL query statement below +WITH + Consecutive AS ( + SELECT + *, + id - ROW_NUMBER() OVER () AS id_diff + FROM Stadium + WHERE people >= 100 + ) +SELECT id, visit_date, people +FROM Consecutive +WHERE + id_diff IN ( + SELECT id_diff + FROM Consecutive + GROUP BY id_diff + HAVING COUNT(*) > 2 + ) +ORDER BY visit_date; \ No newline at end of file From bc7829b6933c2cd18dd2d1c7226a026168308063 Mon Sep 17 00:00:00 2001 From: hhnguyen-20 <79944868+hhnguyen-20@users.noreply.github.com> Date: Wed, 29 Oct 2025 15:43:51 +0000 Subject: [PATCH 4/4] style: format code and docs with prettier --- solution/0600-0699/0601.Human Traffic of Stadium/Solution2.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/0600-0699/0601.Human Traffic of Stadium/Solution2.sql b/solution/0600-0699/0601.Human Traffic of Stadium/Solution2.sql index 81a63fc92b14c..8c1ae30980448 100644 --- a/solution/0600-0699/0601.Human Traffic of Stadium/Solution2.sql +++ b/solution/0600-0699/0601.Human Traffic of Stadium/Solution2.sql @@ -16,4 +16,4 @@ WHERE GROUP BY id_diff HAVING COUNT(*) > 2 ) -ORDER BY visit_date; \ No newline at end of file +ORDER BY visit_date;