Chapter 6: A Typical Query Process
The Sort Order Screen
After you specify your record selection criteria, you are presented with a Sort Order screen. The screen lists all of the fields that you are allowed to designate for sequencing. You have a number of choices for each field. Figure 18 shows a sample Sort Order screen.
A default sort order is designated when you see the Sort Order screen. The first column may have numbers starting with 1, listed in the designated sequence. You can change the sort sequence, designate other fields as sort fields, or remove fields from the sort sequence, by using the options available at the bottom of the screen.
To redefine the sort order, first click the CLEAR SORT LEVELS button. This erases all of the sort level numbers. Then, place the cursor on the item you want to be first in the sort order, and type “1” in the Sort Level column. To choose the second sort level, position the cursor on the item you want second in the sort order, and type “2” for the Sort Level. Continue in this manner until all desired sort levels are defined. Lines without a sort level designated will be ignored.

There are also several other sort-related factors you can control for each sort field, described as follows:
- Subheading allows you to specify whether or not you want a subheading to print on a report each time the value at this level changes and, if so, how it should affect paging. Click the list button to list the valid Subheading entries:
- NO prints no subheading.
- STANDARD prints a subheading immediately before the record that caused the sort level to change.
- NEW PAGE WITH HDG skips to a new page before printing the subheading.
- NEW PAGE ONLY skips to a new page when a range break is encountered but does not print a subheading.
- Subtotal allows you to specify whether you want subtotals to print when the value at this level changes. Click the list button to view the valid Subtotal entries:
- NO prints no subtotals.
- STANDARD prints a subtotal immediately following the last record in this sort level.
- NEW PAGE skips to a new page before printing the subtotal.
- Sort Order allows you to designate if a field should be sorted in ascending (+) or descending (-) order. You can enter your selection or select it from a drop-down list by clicking the respective Scan icon. Ascending is the normal order, which sorts records from low-to-high key values (e.g., CUSTOMER NUMBER 1, then 2, then 3, etc., or CUSTOMER NAME Anderson, Baker, Clinton, etc.). Descending order is useful when, for example, you want to list numeric amounts from largest to smallest.
- At the bottom of the Sort Order screen, you will see a field highlighted for Grand Totals. The values for grand totals are similar to the values for subtotals. Specifically, valid Grand Totals entries can be viewed by clicking the list button:
- NO prints no grand totals.
- STANDARD prints grand totals immediately after the last record or subtotal prints.
- NEW PAGE skips to a new page before printing the grand totals.