Your question is Top 10 Products Last Quarter. 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.
Publicis Commerce analysts need a quarterly view of which catalog products generated the highest unit sales. For this exercise, use a reporting date of 2025-08-15, making the last quarter 2025-04-01 through 2025-06-30.
Write a PostgreSQL query to return the top 10 products by sales volume during the last quarter.
status = 'completed'.2025-04-01 and before 2025-07-01.quantity for each product.product_id, product_name, and sales_volume, ordered from highest to lowest volume. Use product_id as a deterministic tie-breaker and return at most 10 rows.| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(150) | Product name in the catalog |
| 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 order-line identifier |
| order_id | INT | References orders.order_id |
| product_id | INT | References products.product_id |
| quantity | INT | Number of units ordered |