Write a query to find the top three performing service stations in each region based on monthly revenue at Repsol. Use completed sales only and report each station's revenue by calendar month. Return no more than three stations per region and month, resolving equal revenues by the lower station ID.
region_name, revenue_month, station_id, station_name, monthly_revenue, and station_rank.revenue_month, region_name, and station_rank ascending.| Column | Type | Description |
|---|---|---|
| region_codePK | VARCHAR(10) | Unique code identifying a Repsol operating region |
| region_name | VARCHAR(100) | Name of the operating region |
| Column | Type | Description |
|---|---|---|
| station_idPK | INT | Unique service station identifier |
| station_name | VARCHAR(150) | Service station name |
| region_code | VARCHAR(10) | Operating region for the station |
| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique sales transaction identifier |
| station_id | INT | Station where the sale occurred |
| sale_date | DATE | Date of the sales transaction |
| revenue | NUMERIC(12,2) | Revenue generated by the transaction |
| status | VARCHAR(20) | Transaction status |