Skip to content

ORDER BY

SELECT *
FROM Employees
ORDER BY LastName ASC;
+------+----------+------------+
| EmpID| FirstName| LastName|
+------+----------+------------+
| 3 | David| Adams |
| 1 | John | Brown |
| 4 | Chris| Smith |
| 2 | Alice| White |
+------+----------+------------+

The query selects all records from the Employees table and orders them in ascending order (ASC) by the LastName column. Therefore, the result set is sorted from A to Z based on the employees’ last names. In case ASC is not specified, the sorting default is ascending order.