SolveWithSQL

SQL Beginner Challenge 27: Finding Minimum and Maximum Values (MIN / MAX)

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_nametypedescription
product_idINTEGERUnique product ID
nameTEXTProduct name
categoryTEXTProduct category
priceDECIMALProduct price

Sample Data

product_idnamecategoryprice
101Wireless MouseAccessories24.99
102Mechanical KeyboardAccessories89.00
103MonitorDisplays229.99
104USB-C HubAccessories34.50
105Laptop StandWorkspace39.99
106WebcamAccessories59.99

Your Task

Write a SQL query that returns:

  • The lowest price
  • The highest price

Expected Output

min_pricemax_price
24.99229.99

Constraints

  • Use MIN() and MAX()
  • 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 column
  • MAX(price) finds the largest value in the column
  • Both functions ignore NULL values automatically

These functions are commonly used for:

  • Range checks
  • Outlier detection
  • Data validation
  • Pricing analysis

Common Mistakes

  1. Using MIN / MAX on text without understanding sorting
  2. Expecting product names instead of prices
    (That requires a different pattern — coming later.)
  3. Mixing MIN / MAX with non-aggregated columns without GROUP BY

Optional Extension (Mini Bonus)

Try answering these:

  1. What is the cheapest product price above 50?
  2. What is the most expensive product per category?
  3. 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.