Write a SQL query to analyze weekly sales and labor efficiency by location at Delaware North, joining transactions, staffing, and calendar tables. Calculate total sales, total labor hours, sales per labor hour, and each location's efficiency rank within its week.
location_id, week_start, total_sales, labor_hours, sales_per_labor_hour, and efficiency_rank.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| location_id | VARCHAR(20) | Delaware North operating location |
| transaction_date | DATE | Date of the transaction, matching calendar_date |
| sales_amount | DECIMAL(12,2) | Transaction sales amount |
| Column | Type | Description |
|---|---|---|
| staffing_idPK | INT | Unique staffing record identifier |
| location_id | VARCHAR(20) | Delaware North operating location |
| work_date | DATE | Date labor was recorded, matching calendar_date |
| labor_hours | DECIMAL(10,2) | Labor hours recorded for the location and date |
| Column | Type | Description |
|---|---|---|
| calendar_datePK | DATE | Daily calendar date |
| week_start | DATE | Start date of the reporting week |