{ "data": { "question": { "questionId": "601", "questionFrontendId": "601", "boundTopicId": null, "title": "Human Traffic of Stadium", "titleSlug": "human-traffic-of-stadium", "content": "

Table: Stadium

\n\n
\n+---------------+---------+\n| Column Name   | Type    |\n+---------------+---------+\n| id            | int     |\n| visit_date    | date    |\n| people        | int     |\n+---------------+---------+\nvisit_date is the column with unique values for this table.\nEach row of this table contains the visit date and visit id to the stadium with the number of people during the visit.\nAs the id increases, the date increases as well.\n
\n\n

 

\n\n

Write a solution to display the records with three or more rows with consecutive id's, and the number of people is greater than or equal to 100 for each.

\n\n

Return the result table ordered by visit_date in ascending order.

\n\n

The result format is in the following example.

\n\n

 

\n

Example 1:

\n\n
\nInput: \nStadium table:\n+------+------------+-----------+\n| id   | visit_date | people    |\n+------+------------+-----------+\n| 1    | 2017-01-01 | 10        |\n| 2    | 2017-01-02 | 109       |\n| 3    | 2017-01-03 | 150       |\n| 4    | 2017-01-04 | 99        |\n| 5    | 2017-01-05 | 145       |\n| 6    | 2017-01-06 | 1455      |\n| 7    | 2017-01-07 | 199       |\n| 8    | 2017-01-09 | 188       |\n+------+------------+-----------+\nOutput: \n+------+------------+-----------+\n| id   | visit_date | people    |\n+------+------------+-----------+\n| 5    | 2017-01-05 | 145       |\n| 6    | 2017-01-06 | 1455      |\n| 7    | 2017-01-07 | 199       |\n| 8    | 2017-01-09 | 188       |\n+------+------------+-----------+\nExplanation: \nThe four rows with ids 5, 6, 7, and 8 have consecutive ids and each of them has >= 100 people attended. Note that row 8 was included even though the visit_date was not the next day after row 7.\nThe rows with ids 2 and 3 are not included because we need at least three consecutive ids.\n
\n", "translatedTitle": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Hard", "likes": 627, "dislikes": 555, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "{\"headers\": {\"Stadium\": [\"id\", \"visit_date\", \"people\"]}, \"rows\": {\"Stadium\": [[1, \"2017-01-01\", 10], [2, \"2017-01-02\", 109], [3, \"2017-01-03\", 150], [4, \"2017-01-04\", 99], [5, \"2017-01-05\", 145], [6, \"2017-01-06\", 1455], [7, \"2017-01-07\", 199], [8, \"2017-01-09\", 188]]}}", "categoryTitle": "Database", "contributors": [], "topicTags": [ { "name": "Database", "slug": "database", "translatedName": null, "__typename": "TopicTagNode" } ], "companyTagStats": null, "codeSnippets": [ { "lang": "MySQL", "langSlug": "mysql", "code": "# Write your MySQL query statement below\n", "__typename": "CodeSnippetNode" }, { "lang": "MS SQL Server", "langSlug": "mssql", "code": "/* Write your T-SQL query statement below */\n", "__typename": "CodeSnippetNode" }, { "lang": "Oracle", "langSlug": "oraclesql", "code": "/* Write your PL/SQL query statement below */\n", "__typename": "CodeSnippetNode" }, { "lang": "Pandas", "langSlug": "pythondata", "code": "import pandas as pd\n\ndef human_traffic(stadium: pd.DataFrame) -> pd.DataFrame:\n ", "__typename": "CodeSnippetNode" }, { "lang": "PostgreSQL", "langSlug": "postgresql", "code": "-- Write your PostgreSQL query statement below\n", "__typename": "CodeSnippetNode" } ], "stats": "{\"totalAccepted\": \"90.9K\", \"totalSubmission\": \"187.9K\", \"totalAcceptedRaw\": 90936, \"totalSubmissionRaw\": 187893, \"acRate\": \"48.4%\"}", "hints": [], "solution": { "id": "2132", "canSeeDetail": true, "paidOnly": false, "hasVideoSolution": false, "paidOnlyVideo": true, "__typename": "ArticleNode" }, "status": null, "sampleTestCase": "{\"headers\": {\"Stadium\": [\"id\", \"visit_date\", \"people\"]}, \"rows\": {\"Stadium\": [[1, \"2017-01-01\", 10], [2, \"2017-01-02\", 109], [3, \"2017-01-03\", 150], [4, \"2017-01-04\", 99], [5, \"2017-01-05\", 145], [6, \"2017-01-06\", 1455], [7, \"2017-01-07\", 199], [8, \"2017-01-09\", 188]]}}", "metaData": "{\"mysql\": [\"Create table If Not Exists Stadium (id int, visit_date DATE NULL, people int)\"], \"mssql\": [\"Create table Stadium (id int, visit_date DATE NULL, people int)\"], \"oraclesql\": [\"Create table Stadium (id int, visit_date DATE, people int)\", \"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"], \"database\": true, \"name\": \"human_traffic\", \"pythondata\": [\"Stadium = pd.DataFrame([], columns=['id', 'visit_date', 'people']).astype({'id':'Int64', 'visit_date':'datetime64[ns]', 'people':'Int64'})\\n\"], \"postgresql\": [\"\\nCreate table If Not Exists Stadium (id int, visit_date DATE NULL, people int)\"], \"database_schema\": {\"Stadium\": {\"id\": \"INT\", \"visit_date\": \"DATE\", \"people\": \"INT\"}}}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists Stadium (id int, visit_date DATE NULL, people int)", "Truncate table Stadium", "insert into Stadium (id, visit_date, people) values ('1', '2017-01-01', '10')", "insert into Stadium (id, visit_date, people) values ('2', '2017-01-02', '109')", "insert into Stadium (id, visit_date, people) values ('3', '2017-01-03', '150')", "insert into Stadium (id, visit_date, people) values ('4', '2017-01-04', '99')", "insert into Stadium (id, visit_date, people) values ('5', '2017-01-05', '145')", "insert into Stadium (id, visit_date, people) values ('6', '2017-01-06', '1455')", "insert into Stadium (id, visit_date, people) values ('7', '2017-01-07', '199')", "insert into Stadium (id, visit_date, people) values ('8', '2017-01-09', '188')" ], "enableRunCode": true, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"mysql\": [\"MySQL\", \"

MySQL 8.0.

\"], \"mssql\": [\"MS SQL Server\", \"

mssql server 2019.

\"], \"oraclesql\": [\"Oracle\", \"

Oracle Sql 11.2.

\"], \"pythondata\": [\"Pandas\", \"

Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0

\"], \"postgresql\": [\"PostgreSQL\", \"

PostgreSQL 16

\"]}", "libraryUrl": null, "adminUrl": null, "challengeQuestion": null, "__typename": "QuestionNode" } } }