Specifying sort conditions for query results
You can specify the sort conditions that determine the order that the rows are returned in the query results.
About this task
Use the Sort Conditions dialog to specify the sort conditions that will apply to the query results. The Sort Conditions dialog is used when building a query using the Prompted Query editor. Rows can be sorted in ascending (A-Z) or descending (Z-A) order. If you sort query results rows by more than one column, the first column is ordered first, then the second column is ordered within the sort order defined for the first column.
To specify the sort conditions for the query results:
- Open the Sort Conditions window by clicking the Add Sort Condition button in the Sort conditions pane of the Prompted Query editor.
- Specify the columns that will be used to sort
the query results in one of the following ways:
- Select one or more columns from the Columns in the result set list. The Columns in the result set lists the columns that are included in the query results. You can select one or more columns if you are adding a sort condition. You can select only one column if you are changing a sort condition.
- Specify a conditional expression in the Or, enter a condition here field. Click the ellipsis (...) to open an expression builder that will help you build the conditional expression. The expression builder offers a palette of common elements used to create SQL expressions, such as column names, constants, functions, and operators. When you click the expression builder buttons, templates for expression elements are inserted into the expression fields.
- Specify the sort direction.
Click Ascending to specify that the query results will be sorted in ascending (lowest-to-highest) order.
Click Descending to specify that the query results will be sorted in descending (highest-to-lowest) order.
The first column is used for the primary sort; subsequent columns will sort within the first.
- Click Add to add the sort condition
to the query results.
If you are changing a sort condition, click Change.
Repeat this process for each column that you want included in the sort conditions.
When you have finished selecting the columns that will be included in the sort conditions, click Close. The Sort Conditions window closes.