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. |