Your question is SQL for Underperforming Shifts. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
How would you write a query to identify the top 10% of underperforming shifts in a given month?
Use the shifts and shift_targets tables. For this exercise, underperformance is measured by the lowest actual-to-target percentage. Include only shifts in February 2025 with non-null actual units and positive targets.
shift_id, store_id, shift_date, shift_name, actual_units, target_units, and performance_pct| Column | Type | Description |
|---|---|---|
| shift_idPK | INT | Unique shift identifier |
| store_id | INT | Store associated with the shift |
| shift_date | DATE | Calendar date of the shift |
| shift_name | VARCHAR(30) | Shift label |
| actual_units | INT | Units processed during the shift |
| Column | Type | Description |
|---|---|---|
| target_idPK | INT | Unique target record identifier |
| shift_id | INT | Referenced shift identifier |
| target_units | INT | Target units for the shift |