How would you write a query to find the top three sales regions by monthly revenue growth using Common Table Expressions (CTEs)?
Calculate growth for the latest available revenue month compared with the preceding month. Transactions with a NULL revenue are ignored.
region_name, revenue_month, current_revenue, previous_revenue, growth_pct, and growth_rank.growth_rank ascending and region_name ascending for ties.| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique sales region identifier |
| region_name | VARCHAR(50) | Sales region name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| region_id | INT | Referenced sales region |
| sale_date | DATE | Transaction date |
| revenue | NUMERIC(12,2) | Revenue generated by the transaction |