Write a SQL query to identify the top-performing Walgreens Boots Alliance stores by monthly sales and compare each store's sales to its district average. Return the top-ranked store or tied stores for every district and calendar month. Include stores with no sales in a month when calculating district averages.
month_start, district_name, store_id, store_name, monthly_sales, district_average, and sales_vs_district_avg_pct| Column | Type | Description |
|---|---|---|
| district_idPK | INT | Unique district identifier |
| district_name | VARCHAR(100) | District name |
| region | VARCHAR(50) | Geographic region containing the district |
| Column | Type | Description |
|---|---|---|
| store_idPK | INT | Unique store identifier |
| store_name | VARCHAR(120) | Walgreens Boots Alliance store name |
| district_id | INT | District assigned to the store |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sales record identifier |
| store_id | INT | Store associated with the sales record |
| sale_date | DATE | Date of the sale |
| amount | NUMERIC(12,2) | Sales amount for the record |