Each license covers `start_date` to `end_date` inclusive. For each customer merge licenses that overlap OR are adjacent (a license starting the day after the coverage so far ends continues it) into continuous coverage periods. Note that one long license can cover several later short ones. Return `customer_id`, `coverage_start`, `coverage_end`, `days_covered` (inclusive day count). Order by `customer_id`, `coverage_start`.
| Column | Type |
|---|---|
| license_id | INTEGER |
| customer_id | INTEGER |
| start_date | DATE |
| end_date | DATE |
| license_id | customer_id | start_date | end_date |
|---|---|---|---|
| 1 | 1 | 2026-01-01 | 2026-01-31 |
| 2 | 1 | 2026-01-20 | 2026-02-15 |
| 3 | 1 | 2026-02-16 | 2026-02-28 |
| 4 | 1 | 2026-04-01 | 2026-04-30 |
| 5 | 2 | 2026-03-01 | 2026-03-10 |
| customer_id | coverage_start | coverage_end | days_covered |
|---|---|---|---|
| 1 | 2026-01-01 | 2026-02-28 | 59 |
| 1 | 2026-04-01 | 2026-04-30 | 30 |
| 2 | 2026-03-01 | 2026-03-10 | 10 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ Monthly Active Subscriptions and MRR · Teams DAU/MAU Stickiness ›
{{ 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.