Write a SQL query to track weekly operational performance by region at Binance, joining orders, support tickets, and refunds to identify the top drivers of SLA breaches.
Count a breach when the relevant completion or response timestamp is later than its SLA due timestamp. Use each table's operational timestamp to assign its week; unmatched support tickets and refunds should not contribute to a region.
week_start, operational volumes, breach counts, total_sla_breaches, top_driver, prior_week_breaches, and breach_change_pct.region, then week_start.| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique Binance order identifier |
| region | VARCHAR(20) | Operational region |
| created_at | TIMESTAMP | Order creation timestamp |
| sla_due_at | TIMESTAMP | Order fulfillment SLA deadline |
| fulfilled_at | TIMESTAMP | Actual fulfillment timestamp |
| Column | Type | Description |
|---|---|---|
| ticket_idPK | INT | Unique support ticket identifier |
| order_id | INT | Related order identifier |
| opened_at | TIMESTAMP | Ticket opening timestamp |
| response_due_at | TIMESTAMP | First-response SLA deadline |
| first_response_at | TIMESTAMP | Actual first-response timestamp |
| Column | Type | Description |
|---|---|---|
| refund_idPK | INT | Unique refund identifier |
| order_id | INT | Related order identifier |
| requested_at | TIMESTAMP | Refund request timestamp |
| refund_due_at | TIMESTAMP | Refund processing SLA deadline |
| processed_at | TIMESTAMP | Actual refund processing timestamp |