Your question is Top-Selling Products by Month. Start with the requirements and the three 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.
Fashion Nova wants a monthly view of its highest-revenue products. Write a PostgreSQL query that returns the top two products by revenue for every calendar month represented in the order data.
status is completed.quantity * unit_price, grouped by calendar month and product.| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| sku | VARCHAR(30) | Fashion Nova stock keeping unit |
| product_name | VARCHAR(100) | Product display name |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| ordered_at | TIMESTAMP | Timestamp when the order was placed |
| status | VARCHAR(20) | Order lifecycle status |
| Column | Type | Description |
|---|---|---|
| line_idPK | INT | Unique order-line identifier |
| order_id | INT | Referenced order |
| product_id | INT | Referenced product |
| quantity | INT | Number of units in the line item |
| unit_price | NUMERIC(10,2) | Selling price per unit |