compliance_records has one row per filing (entity_id, filing_year); an entity can file more than once in a year. Find every streak of at least three consecutive calendar years in which the entity filed. Output columns: entity_id, streak_start, streak_end (one row per qualifying streak). Order by entity_id, then streak_start.
| Column | Type |
|---|---|
| entity_id | INTEGER |
| filing_year | INTEGER |
| entity_id | filing_year |
|---|---|
| 1 | 2022 |
| 1 | 2023 |
| 1 | 2024 |
| 1 | 2026 |
| 2 | 2021 |
| 2 | 2022 |
| 2 | 2023 |
| 3 | 2022 |
| entity_id | streak_start | streak_end |
|---|---|---|
| 1 | 2022 | 2024 |
| 2 | 2021 | 2023 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
{{ totalCount }} questions in the style asked at Amazon, Microsoft, Google, Meta, Flipkart and more — {{ hardPct }}% Hard. Write SQL in a real database engine in your browser, run it on sample data, then evaluate against hidden tests.
Company tags show where this type of question is commonly reported in interviews. Questions, data and solutions are written by TechTown.
{{ cur.statement }}
No submissions yet. Press Evaluate to submit your query.
{{ solutionSql }}
{{ out.error }}
You have solved your 3 free questions — nice work! Log in (free) to unlock all 150 questions, keep your streak and appear on the leaderboard.