Creating an ORDER BY clause in a SELECT statement
The ORDER BY clause specifies the order of the rows of a results table for an SQL statement.
If a single sort specification 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 indicated sort specification, then by the values of the second identified sort specification, and so on. The ORDER BY clause can be set for both SELECT and FULLSELECT statements.
To create an ORDER BY clause in a SELECT statement:
- Switch to the Data perspective.
- Create a SELECT statement or clause.
- Open the SELECT statement in the SQL Builder.
- Click the Columns tab in the Design pane.
- Click the cell under the Sort Type heading in the row that contains the column or column expression to sort by.
- Select Ascending, Descending, or Default from the list. The Default option indicates that sorting is required, but no SQL source should be shown for the sort type. The default sort type for your database product is used.
- Click the cell under the Sort Order heading.
- Select the number that corresponds to the order in which to sort the results, and then press Enter.
- To sort by additional columns, repeat this process.
To remove the Sort Type, select Unsorted from the Sort Type list.
To remove the ASC or DESC SQL source from your SQL statement, select Default from the Sort Type list.
Parent topic
Creating a SELECT statement