Sort the result and take the first rows

ORDER BY sorts (ASC is the default). LIMIT keeps only the first rows.

SQL · Sort the result and take the first rowsBeginner
SELECT name, price
FROM products
ORDER BY price DESC
LIMIT 3;                          -- the 3 most expensive

SELECT * FROM customers ORDER BY city ASC, name ASC;
order bylimittop