SQLSQL
#34

Find Numbers Appearing at Least Three Times Consecutively in SQL

MediumAmazon
Interview Question #34
Asked at Amazon

Given a `logs` table with `id` (autoincrementing) and `num`, write a SQL query to find all numbers that appear at least three times consecutively.

Input Table: logs
7 rows preview
idnum
11
21
31
42
51
62
72
Expected Output Structure1 rows
ConsecutiveNums
1
Interview Context

Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.

SQLPostgreSQL 15
Ready to execute

Click "Run Query" or press Ctrl + Enter to test your query.

Output will be verified against the test dataset.

Chat with us