Allocations are inclusive date ranges and can overlap or be nested (an employee can be on two projects at once). A bench period is a run of days between allocations when the employee is on no project. Report bench periods longer than 14 days that lie between two allocations (ignore time before the first and after the last allocation). Return emp_id, bench_start, bench_end (first and last day without allocation) and bench_days. Order by emp_id, bench_start.
| Column | Type |
|---|---|
| emp_id | TEXT |
| project_code | TEXT |
| alloc_start | DATE |
| alloc_end | DATE |
| emp_id | project_code | alloc_start | alloc_end |
|---|---|---|---|
| E1 | P1 | 2026-01-01 | 2026-01-31 |
| E1 | P2 | 2026-02-20 | 2026-03-31 |
| E1 | P3 | 2026-04-05 | 2026-04-30 |
| E2 | P4 | 2026-01-01 | 2026-03-31 |
| E2 | P5 | 2026-02-01 | 2026-02-28 |
| E2 | P6 | 2026-04-20 | 2026-05-31 |
| E3 | P7 | 2026-01-10 | 2026-06-30 |
| emp_id | bench_start | bench_end | bench_days |
|---|---|---|---|
| E1 | 2026-02-01 | 2026-02-19 | 19 |
| E2 | 2026-04-01 | 2026-04-19 | 19 |
Solve it in the live editor on this page — run on sample data, then submit against hidden tests.
‹ MRR Movements: New, Expansion, Contraction, Churn · Unbalanced Journal Entries ›
{{ 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.