Find the three most expensive products
Return product_id, name and price for up to three products with a non-NULL price. Sort by price from highest to lowest, then product_id from lowest to highest to break ties. Use LIMIT 3.
Difficulty: beginner
Show hint
Exclude NULL prices before sorting. ORDER BY can use a different direction for each column.
Tables and sample data
Each test starts with fresh tables. Result row order matters for this challenge. Column names and column order must match.
| product_id (integer) | name (text) | price (numeric) |
|---|---|---|
| 1 | Notebook | 5 |
| 2 | Monitor | 220 |
| 3 | Keyboard | 40 |
| 4 | Desk | 180 |
| product_id | name | price |
|---|---|---|
| 2 | Monitor | 220 |
| 4 | Desk | 180 |
| 3 | Keyboard | 40 |