SQL - ORDER BY
Overview
ORDER BY sorts the result set. Use ASC/DESC per column. Some engines support NULLS FIRST/LAST.
SELECT first_name, salary
FROM employees
ORDER BY salary DESC, first_name ASC;
SELECT first_name, salary
FROM employees
ORDER BY salary DESC, first_name ASC;
SELECT first_name, salary
FROM employees
ORDER BY salary DESC, first_name ASC;
Prerequisite
Load the Standard Test Data.
Expected Output
first_name | salary |
---|---|
Eli | 130000 |
Ada | 120000 |
Dee | 110000 |
Bob | 90000 |
Chen | 80000 |