ORDER BY Clause

The ORDER BY clause sorts the results based on the value of one or more specified columns. The syntax of the ORDER BY clause is:

… ORDER BY <column> [ <direction> ] [ , <column> [ <direction> ] ] 

The column specifier must be a valid column. Column name aliases are allowed. Alternatively, the column specifier can refer to columns by the order they appear in the SELECT clause. The first column in the SELECT clause is numbered 1.

More than one column can be included in the ORDER BY clause. Commas should separate them.

The optional direction specifier can be either "ASC" for ascending (low to high) or "DESC" for descending (high to low). If no direction specifier is provided, the default, ascending, is used. If more than one column is specified, but not all directions are specified, the direction specified last is applied to each column until the direction is explicitly changed. For example, in the following ORDER BY clause, the columns A, B, C, and G are sorted in ascending order, while columns D, E, and F are sorted in descending order.

… ORDER BY A ASC, B, C, D DESC, E, F, G ASC

FROM Clause

Full-Text Predicates

Non-Full-Text predicates

RANK BY Clause

Search Error Messages

SELECT Statement

Subscription Query Language