Your question is Consecutive Numbers SQL. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Write a SQL query to find three consecutive numbers in a dataset.
Assume the table is sequence_values, where position_id identifies the sequence position and number_value stores the number. Return each non-null number that appears at three consecutive positions, even when the same number appears in multiple qualifying runs.
consecutive_number.position_id values.consecutive_number in ascending order.| Column | Type | Description |
|---|---|---|
| position_idPK | INT | Sequence position used to determine adjacency |
| number_value | INT | Number recorded at the sequence position |