Select, Filter and Sort · Problem 1 of 118

Expensive Products

EasySelect, Filter and SortShop data

The shop wants a list of its premium products.

Return the name and price of every product that costs more than 50. Show the most expensive first; when two products have the same price, sort them by name.

Hint 1

Filter rows with WHERE. Sort with ORDER BY, and use DESC for largest first.

Hint 2

ORDER BY can take several columns: ORDER BY price DESC, name.

Reference solution

SELECT name, price
FROM products
WHERE price > 50
ORDER BY price DESC, name;

WHERE price > 50 keeps only the rows where the condition is true. ORDER BY price DESC, name sorts the remaining rows: first by price from high to low, then by name for products with the same price. A second sort column is how you make an ordering complete, so the result is the same every time you run it.