SQL Practice Problem #013

Show the two most expensive products

Return the two products with the highest price.

Problem

Task

Return the two products with the highest price.

Schema

Table Schema

products(id, title, category, price)

Input

Sample Data

idtitlecategoryprice
1KeyboardAccessories49.99
2MonitorDisplays219
3Laptop StandAccessories64

Output

Expected Output

idtitlecategoryprice
2MonitorDisplays219
3Laptop StandAccessories64

Answer

Check Your Solution

Show Answer and Explanation

Correct Answer

SELECT *
FROM products
ORDER BY price DESC
LIMIT 2;

Explanation

ORDER BY price DESC puts the highest prices first. LIMIT 2 keeps only the first two rows after sorting.

Common Mistakes

  • Using ASC, which returns the cheapest products first.
  • Applying LIMIT before sorting conceptually.
  • Sorting by id instead of price.

Concepts

Related Concepts

Top N Queries ORDER BY LIMIT Top N

Next practice

Related Problems