Sorting the Result Set

Use the Sort page of the SQLAssist SmartGuide to specify the order of rows in the result set. You specify the order by identifying a column to be used as a sort key. You can specify multiple columns, each one is used as a separate sort key.The rows of the result set are ordered by the value in the selected column, that is by the value of the sort key. If you specify more than one sort key, the rows of the result set are ordered by the value of the first sort key, then by the value of the second sort key, and so on. The sorting specification will appear in the ORDER BY clause of the SQL statement.


Sort page of SQL Assist SmartGuide

  1. Select a table from the Selected table(s) drop-down list. The list includes only the tables that are selected in the Tables page.

  2. Select one or more columns from the Columns list. The list includes the columns for the selected table. Use Select all to select all the columns in the list. Use Deselect all to deselect all selected columns in the list.

  3. Select Add to add the selected columns to the Columns to sort on list. The selected columns are removed from the Columns list.

    To remove one or more columns from the Columns to sort on list, select the columns and select Remove. You can navigate through the list by selecting Move down or Move up. The selected columns are added to the Columns list.

  4. Select a value from the Sort order list. If you select Ascending, the result set is ordered in ascending order by values in the selected columns. If you select Descending, the result set is ordered in descending order by values in the selected columns.

When you finish specifying the result columns, select Next. This displays the Mapping page of the SQLAssist SmartGuide. Use that page to cast the data type of the result to another data type.

Select Back to display the Columns page of the SQLAssist SmartGuide. If appropriate, you can then change the columns to be included in the result set.

You can also display any page in the SQL Assist SmartGuide by selecting its tab.

When you complete the specification of your SQL statement, select Finish. This generates the code for the SQL statement and closes the SQLAssist SmartGuide.

To cancel the visual composition of the SQL statement, select Cancel.