ORDER BY controls the sequence results come back in — it doesn't change which rows are returned, only their order.
Sorts results from lowest to highest (the default direction).
SELECT * FROM table_name
ORDER BY column ASC;SELECT * FROM Employee
ORDER BY salary ASC;Common Mistake
Assuming a result's order without specifying ORDER BY on a column that isn't naturally ordered — without it, order is not guaranteed.
Sorts results from highest to lowest.
SELECT * FROM table_name
ORDER BY column DESC;SELECT * FROM Employee
ORDER BY salary DESC;Common Mistake
Forgetting DESC applies only to the column it directly follows when sorting by multiple columns.
Sorting is straightforward once you know the two keywords. The next lesson covers something a bit bigger: collapsing rows into summarized groups with GROUP BY and HAVING.