60-second card
Sorting
ORDER BY sorts the result by one or more columns.
- ASC (the default) is smallest first; DESC is largest first.
- Sort by several columns: ORDER BY city, marks DESC.
- Without ORDER BY, the row order isn't guaranteed.
SELECT name, marks FROM students ORDER BY marks DESC;Result
Meena | 91
Divya | 88
Asha | 82
Karan | 74
Ravi | 67Remember: If the order matters, always write ORDER BY.
Common mistake: Expecting rows to come back in the order they were added. They might not.