Write a query to identify the top three selling product categories for each region in the last fiscal quarter.
Assume fiscal quarters align with calendar quarters and use the last completed quarter relative to CURRENT_DATE. Include completed orders only, and calculate sales as quantity multiplied by unit price.
region, category, total_sales, and category_rank.region, then category_rank, then category.| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| region | VARCHAR(50) | Customer region associated with the order |
| product_id | INT | Purchased product identifier |
| order_date | DATE | Date the order was placed |
| quantity | INT | Number of units purchased |
| unit_price | NUMERIC(10,2) | Price per unit at the time of purchase |
| status | VARCHAR(20) | Order fulfillment status |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product name |
| category | VARCHAR(50) | Product category |