To specify how you want the rows in a result table to be ordered, specify a SELECT statement with an ORDER BY clause.
After following the steps in this section, you will have created the following query:
SELECT STAFF.NAME, STAFF.ID STAFF.DEPT, STAFF.JOB STAFF.SALARY, STAFF.COMM, STAFF.YEARS FROM STAFF ORDER BY STAFF.DEPT ASC, STAFF.NAME ASC
This query returns staff records that are sorted first by department number in ascending order and then by name in ascending order.
Although this query selects all of the columns in the table, do not use the SELECT * check box. Unlike *, selecting the columns individually enables you to change the sequence of the columns as they will appear in the result table.
Specifying the sequence of columns
Use the pop-up menu on the Column sequence list to change the sequence of the columns to match the example statement you are working on. For example, select STAFF.NAME in the Column sequence list and select Move before > STAFF.COMM. Then select STAFF.COMM in the Column sequence list and select Move after > STAFF.SALARY.
Using the ORDER BY Details window
After you have the columns in the proper sequence, you are ready to specify the order of the result table rows using an ORDER BY clause.
This displays the ORDER BY Details window, which looks like this:
The ORDER BY Details window enables you to specify how you want to sort the rows of the result table.
Specifying the sorting order and precedence
Use the pop-up menu on the ORDER BY sequence list to specify the sorting order and precedence.
The order of the items in the ORDER BY sequence list determines the sorting precedence. Use Move after and Move before to change the order of the items in the list.