ENFORM User's Guide

Sorting and Grouping Selected Information
Developing an ENFORM Query
058058 Tandem Computers Incorporated 3–31
Sorting and Grouping
Selected Information
Sorting the information selected for a report makes the report easier to read. Grouping
the sorted information improves the appearance of the report and more clearly defines
important data.
Sorting the information selected for a FIND file eliminates the need for sorting of the
records when the FIND file is used in a subsequent query. (Remember, the
SEQUENCE IS clause must be used in the DDL record description of the FIND file.)
Table 3-4 shows the ENFORM clauses used to group and sort information.
Table 3-4. Clauses Used to Group and Sort Information
Clause Function
BY Groups and sorts target-records in ascending order according to the value of a field.
BY DESC Groups and sorts target-records in descending order according to the value of a field.
ASCD Sorts target-records in ascending order according to the value of a field.
DESC Sorts target-records in descending order according to the value of a field.
Use the BY and BY DESC clauses to group and sort field values. Field names grouped
and sorted by BY and BY DESC clauses are called by-items. If a BY or BY DESC
clause is specified in a LIST statement, the printing of all duplicate values is
suppressed. For example, consider the following query and report:
OPEN odetail;
LIST BY ordernum,
partnum;
Report:
Part
ORDERNUM Number
-------- ------
21 244
2001
2403
4103
25 244
5103
6301
6402
30 244
2001
... ...
Notice that only the first instance of a value for ordernum appears in the report.