Learn SQL Lesson
Sorting Results
By default, SQL doesn't guarantee a particular row order. To sort your results, use `ORDER BY`:
SELECT * FROM employees ORDER BY salary
This sorts rows by salary in ascending order (lowest first). You can also expressly specify `ASC` for ascending:
SELECT * FROM employees ORDER BY salary ASC
To sort in descending order (highest first), add `DESC`:
SELECT * FROM employees ORDER BY salary DESC
You can sort by multiple columns too:
SELECT * FROM employees ORDER BY department, name
This sorts by department first, then by name within each department.
Practice challenge
Select the name and salary of all employees, sorted by salary from highest to lowest.