Citizant's federal sales reporting dataset contains orders, line items, products, and product categories. Write a PostgreSQL query that identifies the five highest-selling categories within each calendar month.
completed.quantity * unit_price at the line-item level, then aggregate by month and category.| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| order_date | DATE | Date the order was placed |
| status | VARCHAR(20) | Order processing status |
| Column | Type | Description |
|---|---|---|
| order_item_idPK | INT | Unique line-item identifier |
| order_id | INT | References sales_orders.order_id |
| product_id | INT | References products.product_id |
| quantity | INT | Number of units sold |
| unit_price | NUMERIC(10,2) | Price charged per unit |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product display name |
| category_id | INT | References categories.category_id |
| Column | Type | Description |
|---|---|---|
| category_idPK | INT | Unique category identifier |
| category_name | VARCHAR(100) | Product category name |