Sorting and limiting
Lesson 4 of 24 · SQL.Micro
ORDER BY sorts the result; LIMIT keeps only the first rows. Together they answer 'top N' questions.
ORDER BY price DESC sorts from highest to lowest; ASC (the default) from lowest to highest.
Without ORDER BY, the order of rows is not guaranteed.
Check yourself
What does ORDER BY name do by default?
Show the 3 most expensive products (name, price), most expensive first.
Do it in the browser: a real SQL tool, a short mission and instant feedback. No install.
Start this lesson — free