A second column breaks the ties
Sort by grade and lots of students share the same grade — SQL has to put them in some order. Name a second column after a comma and it decides only those ties. DESC applies just to the column it follows, so the first column can be descending while the second stays ascending.
A tiny example
In plain English: Show me every student's name and grade, highest grade first, and sort students in the same grade by name.
SELECT name, grade
FROM students
ORDER BY grade DESC, name;What comes back
| name | grade |
|---|---|
| Kai | 12 |
| Zoe | 12 |
| Amy | 11 |
Kai and Zoe tie on grade 12, so the second column settles it by name, A before Z.
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