SQL Beginner Challenge 19: Limiting Results with LIMIT

Difficulty: Beginner
Estimated time: 10–15 minutes
SQL concepts: LIMIT, controlling result size
Goal: Return only a specific number of rows from a query.

The Scenario

A product manager asks:

“Can you show me only the 3 cheapest products?”

When working with large datasets, you rarely want all rows.
LIMIT lets you cap how many results are returned.

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
10327-inch MonitorDisplays229.99
104USB-C HubAccessories34.50
105Laptop StandWorkspace39.99
106WebcamAccessories59.99

Your Task

Write a SQL query that returns:

  • name
  • price

…but only the 3 cheapest products.

Expected Output

nameprice
Wireless Mouse24.99
USB-C Hub34.50
Laptop Stand39.99

Constraints

  • Use ORDER BY
  • Use LIMIT
  • Do not use SELECT *

Hint (Optional)

To get the cheapest items:

  1. Sort by price (ascending)
  2. Limit the number of rows returned

Order matters.

SELECT
name,
price
FROM products
ORDER BY price ASC
LIMIT 3;

Explanation

  • ORDER BY price ASC sorts from cheapest to most expensive
  • LIMIT 3 returns only the first three rows
  • Without sorting first, LIMIT alone gives unpredictable results

Common Mistakes

  1. Using LIMIT without ORDER BY
  2. Assuming LIMIT always returns the same rows
  3. Putting LIMIT before ORDER BY

Optional Extension (Mini Bonus)

Try:

  1. Show the 5 most expensive products
  2. Combine LIMIT with WHERE
  3. Add OFFSET to skip rows

Next Challenge

Beginner Challenge #20: Skipping Rows with OFFSET

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