Write a SQL query to analyze store-level performance by joining sales, labor, and inventory tables and identifying locations with the highest food waste. Aggregate all available records by location and preserve locations that appear in only one source.
store_code, total_sales, total_units_sold, total_labor_hours, total_labor_cost, inventory_received_units, food_waste_units, food_waste_pct, and waste_rank.store_code.| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sales record identifier |
| store_code | VARCHAR(10) | Avi location code |
| sale_date | DATE | Date of the sales record |
| sales_amount | NUMERIC(12,2) | Sales revenue for the record |
| units_sold | INT | Food units sold |
| Column | Type | Description |
|---|---|---|
| labor_idPK | INT | Unique labor record identifier |
| store_code | VARCHAR(10) | Avi location code |
| work_date | DATE | Date of the labor record |
| labor_hours | NUMERIC(8,2) | Hours worked |
| labor_cost | NUMERIC(12,2) | Cost of labor |
| Column | Type | Description |
|---|---|---|
| inventory_idPK | INT | Unique inventory record identifier |
| store_code | VARCHAR(10) | Avi location code |
| inventory_date | DATE | Date of the inventory record |
| received_units | INT | Food units received |
| waste_units | INT | Food units discarded |