Write a SQL query to calculate labor hours, package volume, and productivity by shift using multiple tables.
Use the provided UPS shift, labor, and package-volume data. Include every shift, treat missing labor or package values as zero, and return productivity as package volume divided by labor hours. Return NULL productivity when labor hours are zero.
shift_date, shift_name, labor_hours, package_volume, and productivityshift_date, shift_name, and shift_id| Column | Type | Description |
|---|---|---|
| shift_idPK | INT | Unique shift identifier |
| shift_date | DATE | Operating date of the shift |
| shift_name | VARCHAR(30) | Shift label such as Day or Night |
| Column | Type | Description |
|---|---|---|
| labor_idPK | INT | Unique labor record identifier |
| shift_id | INT | Referenced shift |
| employee_id | INT | Employee assigned to the shift |
| hours_worked | NUMERIC(6,2) | Hours worked by the employee |
| Column | Type | Description |
|---|---|---|
| volume_idPK | INT | Unique package-volume record identifier |
| shift_id | INT | Referenced shift |
| package_count | INT | Packages processed in the record |