{ "data": { "question": { "questionId": "180", "questionFrontendId": "180", "boundTopicId": null, "title": "Consecutive Numbers", "titleSlug": "consecutive-numbers", "content": "
Table: Logs
\n+-------------+---------+\n| Column Name | Type |\n+-------------+---------+\n| id | int |\n| num | varchar |\n+-------------+---------+\nid is the primary key for this table.\nid is an autoincrement column.\n\n\n
\n\n
Write an SQL query to find all numbers that appear at least three times consecutively.
\n\nReturn the result table in any order.
\n\nThe query result format is in the following example.
\n\n\n
Example 1:
\n\n\nInput: \nLogs table:\n+----+-----+\n| id | num |\n+----+-----+\n| 1 | 1 |\n| 2 | 1 |\n| 3 | 1 |\n| 4 | 2 |\n| 5 | 1 |\n| 6 | 2 |\n| 7 | 2 |\n+----+-----+\nOutput: \n+-----------------+\n| ConsecutiveNums |\n+-----------------+\n| 1 |\n+-----------------+\nExplanation: 1 is the only number that appears consecutively for at least three times.\n\n", "translatedTitle": null, "translatedContent": null, "isPaidOnly": false, "difficulty": "Medium", "likes": 975, "dislikes": 187, "isLiked": null, "similarQuestions": "[]", "exampleTestcases": "{\"headers\": {\"Logs\": [\"id\", \"num\"]}, \"rows\": {\"Logs\": [[1, 1], [2, 1], [3, 1], [4, 2], [5, 1], [6, 2], [7, 2]]}}", "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" } ], "stats": "{\"totalAccepted\": \"185.9K\", \"totalSubmission\": \"407.8K\", \"totalAcceptedRaw\": 185881, \"totalSubmissionRaw\": 407785, \"acRate\": \"45.6%\"}", "hints": [], "solution": { "id": "216", "canSeeDetail": true, "paidOnly": false, "hasVideoSolution": false, "paidOnlyVideo": true, "__typename": "ArticleNode" }, "status": null, "sampleTestCase": "{\"headers\": {\"Logs\": [\"id\", \"num\"]}, \"rows\": {\"Logs\": [[1, 1], [2, 1], [3, 1], [4, 2], [5, 1], [6, 2], [7, 2]]}}", "metaData": "{\n \"mysql\": [\n \"Create table If Not Exists Logs (id int, num int)\"\n ],\n \"mssql\": [\n \"Create table Logs (id int, num int)\"\n ],\n \"oraclesql\": [\n \"Create table Logs (id int, num int)\"\n ],\n \"database\": true\n}", "judgerAvailable": true, "judgeType": "large", "mysqlSchemas": [ "Create table If Not Exists Logs (id int, num int)", "Truncate table Logs", "insert into Logs (id, num) values ('1', '1')", "insert into Logs (id, num) values ('2', '1')", "insert into Logs (id, num) values ('3', '1')", "insert into Logs (id, num) values ('4', '2')", "insert into Logs (id, num) values ('5', '1')", "insert into Logs (id, num) values ('6', '2')", "insert into Logs (id, num) values ('7', '2')" ], "enableRunCode": true, "enableTestMode": false, "enableDebugger": false, "envInfo": "{\"mysql\": [\"MySQL\", \"
MySQL 8.0
.
mssql server 2019
.
Oracle Sql 11.2
.