Progress
SQL-89
Guide and Reference
Sorting Data
The ORDER BY clause of a SELECT statement sorts query results by the values in one or more columns. You can specify the columns by name or by order within the SELECT statement. The ORDER BY clause has the following syntax.
The following example of the ORDER BY clause sorts the data alphabetically by state and, within each state, alphabetically by city:
As an alternative to column names, you can specify integers in the ORDER BY clause. The integer refers to the position of the column in the column list. In the following example, the 2 refers to the SUM column.
Ascending is the default sort order. You can specify the keyword DESC to sort the results in descending order.
Two null values are considered equal within the context of GROUP BY, ORDER BY, and DISTINCT clauses. In ORDER BY clauses, null values are also considered greater than all non-null values. When the sort order is ascending, null values are sorted last. When the sort order is descending, null values are sorted first.
NOTE
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |