QuickBooks Online analytics needs a regional view of completed product revenue. Write a PostgreSQL query that identifies the top three product categories by revenue within each sales region.
quantity * unit_price.| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| region_id | INT | Reference to the sales region |
| product_id | INT | Reference to the purchased product |
| quantity | INT | Number of units ordered |
| unit_price | DECIMAL(10,2) | Price per unit |
| order_status | VARCHAR(20) | Current order status |
| order_date | DATE | Date the order was placed |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product display name |
| category | VARCHAR(50) | Product category |
| Column | Type | Description |
|---|---|---|
| region_idPK | INT | Unique region identifier |
| region_name | VARCHAR(50) | Sales region name |