다음을 통해 공유


ORDER BY Clause

Topic Last Modified: 2006-06-13

The Structured Query Language (SQL) ORDER BY clause sorts the returned recordset in ascending or descending order according to one or more properties specified.

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"

See Also

Other Resources

SELECT Statement