Write a SQL query to calculate weekly labor hours, average productivity, and variance from target by site.
Use the supplied tables and include every site-week with labor activity, including rows where no productivity target is available.
site_name, week_start, total_labor_hours, average_productivity, target_productivity, and variance_from_target.| Column | Type | Description |
|---|---|---|
| site_idPK | INT | Unique Tennessee Staffing site identifier |
| site_name | VARCHAR(100) | Site display name |
| region | VARCHAR(50) | Operating region for the site |
| Column | Type | Description |
|---|---|---|
| labor_record_idPK | INT | Unique labor record identifier |
| site_id | INT | Site where the labor was recorded |
| work_date | DATE | Date of the labor activity |
| hours_worked | NUMERIC(6,2) | Labor hours recorded |
| productivity_units | NUMERIC(10,2) | Productivity units recorded for the labor activity |
| Column | Type | Description |
|---|---|---|
| target_idPK | INT | Unique target record identifier |
| site_id | INT | Site associated with the productivity target |
| target_productivity | NUMERIC(10,2) | Expected productivity units for the site |