Difficulty: Beginner
Estimated time: 10–15 minutes
SQL concepts: MIN(), MAX(), identifying extremes
Goal: Find the lowest and highest values in a dataset.
The Challenge
The product manager asks:
“What is the cheapest and most expensive product we sell?”
This is a classic business question used in:
- Pricing reviews
- Product positioning
- Market comparisons
Instead of totals or averages, you’re now looking for extremes.
Database Table
products
| column_name | type | description |
|---|---|---|
| product_id | INTEGER | Unique product ID |
| name | TEXT | Product name |
| category | TEXT | Product category |
| price | DECIMAL | Product price |
Sample Data
| product_id | name | category | price |
|---|---|---|---|
| 101 | Wireless Mouse | Accessories | 24.99 |
| 102 | Mechanical Keyboard | Accessories | 89.00 |
| 103 | Monitor | Displays | 229.99 |
| 104 | USB-C Hub | Accessories | 34.50 |
| 105 | Laptop Stand | Workspace | 39.99 |
| 106 | Webcam | Accessories | 59.99 |
Your Task
Write a SQL query that returns:
- The lowest price
- The highest price
Expected Output
| min_price | max_price |
|---|---|
| 24.99 | 229.99 |
Constraints
- Use
MIN()andMAX() - Return one row
- Do not use
SELECT *
Hint (Optional)
MIN() and MAX() work just like SUM() and AVG() — they operate across multiple rows and return single values.
SELECT
MIN(price) AS min_price,
MAX(price) AS max_price
FROM products;
Explanation
MIN(price)finds the smallest value in the columnMAX(price)finds the largest value in the column- Both functions ignore
NULLvalues automatically
These functions are commonly used for:
- Range checks
- Outlier detection
- Data validation
- Pricing analysis
Common Mistakes
- Using MIN / MAX on text without understanding sorting
- Expecting product names instead of prices
(That requires a different pattern — coming later.) - Mixing MIN / MAX with non-aggregated columns without GROUP BY
Optional Extension (Mini Bonus)
Try answering these:
- What is the cheapest product price above 50?
- What is the most expensive product per category?
- What is the price range (max − min)?
Why this challenge matters
MIN and MAX help you understand boundaries:
- What’s too cheap?
- What’s too expensive?
- Where do most products sit?
Once learners know COUNT, SUM, AVG, MIN, and MAX, they can answer a huge percentage of real business questions with SQL.
Next Challenge
Beginner Challenge #28: Sorting Aggregated Results (ORDER BY with Aggregates)
🔗 View reference solution on GitHub
(After you’ve tried the challenge)
Want more practical SQL challenges?
Subscribe to the Solve With SQL newsletter and get new problems delivered to your inbox.