Find streaks of at least 3 consecutive FAILED runs per job, ordered by started_at (ties by run_id). CANCELLED runs are ignored completely: they neither count nor break a streak; a SUCCESS breaks it. Return job_name, streak_start (started_at of the first failure), streak_end (started_at of the last failure) and failed_runs. A job can have several streaks. Order by job_name, streak_start.
| Column | Type |
|---|---|
| run_id | INTEGER |
| job_name | TEXT |
| started_at | TIMESTAMP |
| result | TEXT |
| run_id | job_name | started_at | result |
|---|---|---|---|
| 1 | etl_orders | 2026-05-01 01:00:00 | SUCCESS |
| 2 | etl_orders | 2026-05-01 02:00:00 | FAILED |
| 3 | etl_orders | 2026-05-01 03:00:00 | FAILED |
| 4 | etl_orders | 2026-05-01 04:00:00 | FAILED |
| 5 | etl_orders | 2026-05-01 05:00:00 | SUCCESS |
| 6 | etl_orders | 2026-05-01 06:00:00 | FAILED |
| 7 | ml_train | 2026-05-01 00:30:00 | FAILED |
| 8 | ml_train | 2026-05-01 01:30:00 | FAILED |
| job_name | streak_start | streak_end | failed_runs |
|---|---|---|---|
| etl_orders | 2026-05-01 02:00:00 | 2026-05-01 04:00:00 | 3 |
| ml_train | 2026-05-01 03:30:00 | 2026-05-01 06:30:00 | 4 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Month-over-Month Credit Spikes · Explode a Bill of Materials ›
{{ 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.