ORDER BY Clause (SQL Only)

See AlsovbhowSQLORDERBYSee                 ExamplevbhowSQLORDERBYEx>Low

Description

ORDER BY sorts the displayed data in the order specified in the clause.

Notes

         ORDER BY is optional.  If you don't include it, the data appears unsorted.

         The default sort order is ascending (A-Z, 0-9).  However, you may want to include the ASC reserved word at the end of each column you want to sort in ascending order.  Both of the following examples sort employee names in last name order:

  SELECT [Last Name], [First Name]
  FROM Employees
  ORDER BY [Last Name]

 

  SELECT [Last Name], [First Name]
  FROM Employees
  ORDER BY [Last Name] ASC

 

         To sort in reverse order (Z-A, 9-0), add the DESC reserved word to the end of each column you want to sort in descending order.  The following example selects salaries and sorts them in descending order.

  SELECT [Last Name], Salary
  FROM Employees
  ORDER BY Salary DESC, [Last Name];

 

         ORDER BY is usually the last item in an SQL statement.