Your question is SQL Top 5 by Sales Volume. 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.
Octane wants to identify which products generate the highest sales volume. Write a PostgreSQL query that ranks products by the total number of units sold in completed orders.
status = 'completed'.quantity by product, preserving products with no qualifying sales.product_id ascending as the tie-breaker.| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| product_name | VARCHAR(100) | Product display name |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| status | VARCHAR(20) | Current order status |
| Column | Type | Description |
|---|---|---|
| order_id | INT | Order containing the item |
| product_id | INT | Product included in the order line |
| quantity | INT | Number of units on the order line |