ORDER BY puts the rows in order
Rows come back in no promised order, so if you want a first or a last, you have to ask. ORDER BY sorts by the column you name. Left alone it sorts ascending — smallest number first, A before Z. Add DESC after that column name to sort descending instead. Sorting happens last, on whatever rows survived the filters.
A tiny example
In plain English: Show me every student's name and score, highest score first.
SELECT name, score
FROM students
ORDER BY score DESC;What comes back
| name | score |
|---|---|
| Nia | 98 |
| Theo | 91 |
| Ravi | 87 |
Same rows as a plain SELECT — just sorted so the highest score comes first.
Related SQL lessons
Ready for a break?
Take on today's cozy puzzle. A fresh, bite-sized query waits every morning — no timers, no pressure.
play today's sip