Write a SQL query to analyze operational performance by region and month, joining transactions and staffing tables to identify trends in efficiency.
Return monthly transaction totals, staffing hours, efficiency, and the percentage change in efficiency from the prior month. Include months present in either table and preserve regions or months with no matching records.
region, month, transaction_count, total_transaction_amount, staffed_hours, efficiency, and efficiency_trend_pct.NULL when staffed hours are missing or zero.region ascending with NULL regions last, then month ascending.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| region | VARCHAR(50) | Operational region associated with the transaction |
| transaction_date | DATE | Date of the transaction |
| transaction_amount | NUMERIC(12,2) | Transaction amount |
| Column | Type | Description |
|---|---|---|
| staffing_idPK | INT | Unique staffing record identifier |
| region | VARCHAR(50) | Operational region associated with staffing |
| staffing_date | DATE | Date represented by the staffing record |
| staffed_hours | NUMERIC(10,2) | Staffed hours available for the record |