Applying a sort order

To sort the Employee table by LastName, add the keywords ORDER BY:

SELECT Department, FirstName, LastName FROM Employee ORDER BY LastName;

To make sure "Andreas" appears before "Jim", sort on both FirstName and LastName:

SELECT Department, FirstName, LastName FROM Employee ORDER BY LastName, FirstName;

To reverse the order, add the keyword for descend as follows:

SELECT Department, FirstName, LastName FROM Employee ORDER BY LastName DESC, FirstName;

See also:

Next topic - Selecting top records only

Selecting records - the basics

Other types of SQL statements