Sorting

ORDER BY sorts your results by one or more columns.

Ascending and descending

Sorting is ascending (smallest/earliest first) by default. Add DESC for descending order:

order by salary descending
Result

Limiting results

LIMIT caps how many rows come back — useful for questions like "who are the top 3 earners?"

top 3 earners
Result
Note: without ORDER BY, a database doesn't guarantee any particular row order — if the order matters, always specify it explicitly.