Microsoft SQL Server Simple ORDER BY clause


Example

Using the Employees Table, below is an example to return the Id, FName and LName columns in (ascending) LName order:

SELECT Id, FName, LName FROM Employees
ORDER BY LName

Returns:

IdFNameLName
2JohnJohnson
1JamesSmith
4JohnathonSmith
3MichaelWilliams

To sort in descending order add the DESC keyword after the field parameter, e.g. the same query in LName descending order is:

SELECT Id, FName, LName FROM Employees
ORDER BY LName DESC