SQL ORDER BY Clause
You can sort your results with ORDER BY:
- β¬οΈ ASC (default, A β Z)
- β¬οΈ DESC (Z β A)
SELECT name [...] ORDER BY name;
SELECT name [...] ORDER BY name ASC;
SELECT name [...] ORDER BY name DESC;
SELECT name [...] ORDER BY name, age DESC;
SELECT name [...] ORDER BY name ASC, age DESC;
You can reference the nth attribute of the select. It's useful when the nth attribute is not a column, but a calculation or something dynamic.
SELECT name [...] ORDER BY 1 DESC;