Workforce and service coverage · Original fictional data · Free files and full answers
Separate booked paid time from overlapping assignments
Per employee/day return booked_paid_minutes summing shift durations less breaks, and shift_count. Do not silently deduplicate overlapping shifts; this is the payroll claim total for review. Sort employee,day.
Use this fixed business case to build a checked CSV and a replayable SQL handoff. No account required. Scenario datasets are shared across related exercises; each exercise has its own decision and output contract.
Your output contract
- Per employee/day return booked_paid_minutes summing shift durations less breaks, and shift_count. Do not silently deduplicate overlapping shifts; this is the payroll claim total for review. Sort employee,day.
- Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
- These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.
Return columns exactly as employee, day, booked_paid_minutes, shift_count. Sort order follows the task. Output has 9 rows; an empty CSV field means NULL.
Source data
shifts
10 source rows · Download shifts CSV
| id INTEGER | employee TEXT | day INTEGER | start INTEGER | end INTEGER | break_minutes INTEGER | role TEXT |
|---|---|---|---|---|---|---|
| 1 | Ann | 0 | 1320 | 360 | 30 | lead |
| 2 | Ann | 1 | 400 | 880 | 30 | lead |
| 3 | Ann | 2 | 500 | 1100 | 60 | desk |
| 4 | Bo | 0 | 480 | 1020 | 30 | desk |
| 5 | Bo | 1 | 500 | 980 | 30 | desk |
| 6 | Bo | 1 | 900 | 1200 | 0 | desk |
| 7 | Cy | 0 | 600 | 1200 | 60 | lead |
| 8 | Cy | 2 | 540 | 1080 | 30 | lead |
| 9 | Dee | 1 | 480 | 1080 | 60 | desk |
| 10 | Dee | 2 | 480 | 1080 | 60 | desk |
skills
6 source rows · Download skills CSV
| employee TEXT | skill TEXT |
|---|---|
| Ann | lead |
| Ann | desk |
| Bo | desk |
| Cy | lead |
| Cy | desk |
| Dee | desk |
leave_events
7 source rows · Download leave_events CSV
| id INTEGER | employee TEXT | days INTEGER | kind TEXT |
|---|---|---|---|
| 1 | Ann | 10 | grant |
| 2 | Ann | 3 | use |
| 3 | Ann | 1 | reverse_use |
| 4 | Bo | 8 | grant |
| 5 | Bo | 9 | use |
| 6 | Cy | 12 | grant |
| 7 | Cy | 2 | use |
crew_cost
4 source rows · Download crew_cost CSV
| employee TEXT | hourly_cents INTEGER |
|---|---|
| Ann | 500 |
| Bo | 1500 |
| Cy | 3000 |
| Dee | 1000 |
Field dictionary and schema
shifts: id INTEGER — Stable source record identifier; not a row position. employee TEXT — Literal business key or category label. Match exactly and retain NULL where present. day INTEGER — Integer day index, or ISO YYYY-MM-DD date when stored as text; the task declares cutoff semantics. start INTEGER — Beginning boundary; inclusive under the task interval policy. end INTEGER — Ending boundary; exclusive unless the goal states otherwise. break_minutes INTEGER — Unpaid break duration deducted from the shift elapsed minutes. role TEXT — Literal business key or category label. Match exactly and retain NULL where present. skills: employee TEXT — Literal business key or category label. Match exactly and retain NULL where present. skill TEXT — Literal business key or category label. Match exactly and retain NULL where present. leave_events: id INTEGER — Stable source record identifier; not a row position. employee TEXT — Literal business key or category label. Match exactly and retain NULL where present. days INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task. kind TEXT — Literal business key or category label. Match exactly and retain NULL where present. crew_cost: employee TEXT — Literal business key or category label. Match exactly and retain NULL where present. hourly_cents INTEGER — Exact integer monetary cents; no implicit currency conversion.
A method you can reuse
- Per employee/day return booked_paid_minutes summing shift durations less breaks, and shift_count. Do not silently deduplicate overlapping shifts; this is the payroll claim total for review. Sort employee,day.
- For the first output record, employee = Ann; day = 0; booked_paid_minutes = 450; shift_count = 1.
- Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.
Watch for this wrong turn
Taking the longest shift drops a separate payroll claim that needs overlap review.
Run and check in SQLite
Your SQL runs locally in the existing SQLite worker. The checker compares every column, row, type, value and row order with this fixed output. It accepts equivalent SELECT or WITH queries. Browser storage keeps your SQL on this device when available.
Complete worked SQL and expected output
SELECT employee,day,SUM(CASE WHEN end<start THEN end+1440 ELSE end END-start-break_minutes) booked_paid_minutes,COUNT(*) shift_count FROM shifts GROUP BY employee,day ORDER BY employee,day;
"employee","day","booked_paid_minutes","shift_count" "Ann","0","450","1" "Ann","1","450","1" "Ann","2","540","1" "Bo","0","510","1" "Bo","1","750","2" "Cy","0","540","1" "Cy","2","510","1" "Dee","1","540","1" "Dee","2","540","1"Reference SQL · Complete expected CSV · Empty answer CSV
Choose another SQL task · Original data exception cases · Larger workplace projects