ORDER BY

<order_by_clause> ::= ORDER BY <field_expr_list> [ ASC | DESC ]
<field_expr_list> ::= <field_expr> [ , <field_expr> ... ]

The ORDER BY clause specifies which SELECT clause field-expressions the query output records should be sorted by.


Arguments:

ASC

Specifies that the field-expression list values should be sorted in ascending order, from lowest value to highest value. ASC is the default.

DESC

Specifies that the field-expression list values should be sorted in descending order, from highest value to lowest value.

Remarks:


Examples:

A. Sorting by a single field-expression

SELECT date, cs-uri-stem, cs-uri-query, sc-bytes
FROM LogFiles\ex040528.log
ORDER BY sc-bytes DESC

B. Sorting by multiple field-expressions

SELECT date, cs-uri-stem, cs-uri-query, sc-bytes
FROM LogFiles\ex040528.log
ORDER BY date, sc-bytes

See also:

Field Expressions
SELECT

Sorting Output Records


© 2004 Microsoft Corporation. All rights reserved.