Your question is Top 5 Categories by Month. Start with the requirements and the four tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
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 |