Your question is SQL Top 10 Products by Sales. Start with the requirements and the one table 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.
SMX tracks product-level sales events in its commerce reporting pipeline. The data science team needs a quick ranking of products with the highest completed sales volume.
Write a PostgreSQL query to return the top 10 SMX products by total completed units sold.
sale_status is completed, then group records by product_name and sum units_sold.product_name and total_units_sold, ordered from highest to lowest volume. Treat a product with only missing unit values as zero, and use product name as a deterministic tie-breaker.| Column | Type | Description |
|---|---|---|
| sale_idPK | INT | Unique identifier for a product sales event. |
| product_name | VARCHAR(100) | Name of the SMX product. |
| units_sold | INT | Number of units in the sales event. |
| sale_status | VARCHAR(20) | Processing status of the sales event. |
| sale_date | DATE | Date the sales event was recorded. |