Skip to content

Commit 0fc836b

Browse files
refactor 601
1 parent 598b150 commit 0fc836b

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

database/_601.sql

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,3 @@
1-
-- 601. Human Traffic of Stadium
2-
--
3-
--X city built a new stadium, each day many people visit it and the stats are saved as these columns: id, date, people
4-
--
5-
--Please write a query to display the records which have 3 or more consecutive rows and the amount of people more than 100(inclusive).
6-
--For example, the table stadium:
7-
--
8-
--+------+------------+-----------+
9-
--| id | date | people |
10-
--+------+------------+-----------+
11-
--| 1 | 2017-01-01 | 10 |
12-
--| 2 | 2017-01-02 | 109 |
13-
--| 3 | 2017-01-03 | 150 |
14-
--| 4 | 2017-01-04 | 99 |
15-
--| 5 | 2017-01-05 | 145 |
16-
--| 6 | 2017-01-06 | 1455 |
17-
--| 7 | 2017-01-07 | 199 |
18-
--| 8 | 2017-01-08 | 188 |
19-
--+------+------------+-----------+
20-
--
21-
--For the sample data above, the output is:
22-
--
23-
--+------+------------+-----------+
24-
--| id | date | people |
25-
--+------+------------+-----------+
26-
--| 5 | 2017-01-05 | 145 |
27-
--| 6 | 2017-01-06 | 1455 |
28-
--| 7 | 2017-01-07 | 199 |
29-
--| 8 | 2017-01-08 | 188 |
30-
--+------+------------+-----------+
31-
--
32-
--Note:
33-
--Each day only have one row record, and the dates are increasing with id increasing.
34-
351
SELECT s1.* FROM stadium AS s1, stadium AS s2, stadium as s3
362
WHERE
373
((s1.id + 1 = s2.id

0 commit comments

Comments
 (0)