Share via


ORDER BY Clause

ORDER BY Clause

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release. The Structured Query Language (SQL) ORDER BY clause sorts the returned recordset in ascending or descending order according to one or more properties specified.

Syntax

ORDER BY [[propertyName] ASC|DESC], [[propertyName] ASC|DESC], [...]

The parameter propertyName specifies properties selected in your SQL query that you want to group.

The parameters "asc" and "desc" specify the sort order. To sort in ascending order, A-Z, specify "asc". To sort in descending order, Z-A, specify "desc". Sorting can also be done numerically.

Remarks

You cannot use ORDER BY on properties in the Exchange store that are calculated. For a list of these properties, see Non-Searchable Properties.

Example

The following is an example of a SELECT Statement that searches the specified folder for only folder resources, and sorts the results in ascending order by displayname Field values.

strSQL = "SELECT ""DAV:displayname""
strSQL = strSQL & "FROM scope('shallow traversal of "http://myserver/public/test/""')"
strSQL = strSQL & "WHERE ""DAV:isfolder"" = TRUE"
strSQL = strSQL & "ORDER BY ""DAV:displayname"" ASC"

Send us your feedback about the Microsoft Exchange Server 2003 SDK.

Build: June 2007 (2007.618.1)

© 2003-2006 Microsoft Corporation. All rights reserved. Terms of use.