Order rows in the result set (ORDER BY clause)
You must select source tables for an SQL statement before you can specify sort columns.
The ORDER BY clause specifies an ordering of the rows of the result table. If a single sort specification (one sort key with associated direction) is identified, the rows are ordered by the values of that sort specification. If more than one sort specification is identified, the rows are ordered by the values of the first identified sort specification, then by the values of the second identified sort specification, and so
on.
These steps are part of the larger task of creating SELECT statements. When you complete the steps for ordering rows in the result set (ORDER BY clause), return to Create a SELECT
statement.
To order rows in the result set:
- In the Outline view, click the ORDER BY (Sort criteria) node. A list of
available columns is displayed in the Details area.
- Optional: Click Show all available columns to show columns from all
tables in the SQL statement in the list of available columns, or Show
result columns only to show only result columns in the list of available
columns.
- Select columns from the Available columns list.
- Click > to move selected columns to the Selected columns list. The selected columns are added to the SQL statement in the SQL
code view.
- Optional: Specify whether the columns should be ordered in ascending or descending order by clicking ASC or DESC in the field next to a column in the Selected columns list.
Return to Create a SELECT statement.