ENFORM Reference Manual
BY AND BY DESC Clauses
Clauses
058057 Tandem Computers Incorporated 5–33
BY and BY DESC
Clauses
The BY and BY DESC clauses group and sort target-records according to the value of a
specified field. The syntax of the BY and BY DESC clauses is:
{}
BY
BY DESC
by-item
by-item
is the name of a field from an input record whose values are to be used to group
and sort target-records.
BY and BY DESC clauses group and sort records according to the field values. The BY
clause sorts the records in ascending order according to the value of the specified field;
the BY DESC clause sorts in descending order. The following example groups and
sorts the partnum field:
BY partnum,
When more than one sort is specified, ENFORM uses a major to minor sort
precedence. ENFORM determines the sort precedence by the order in which a BY or
BY DESC clause appears in a LIST or FIND statement. The first BY or BY DESC clause
has the highest priority, the next one second priority, down to the last BY or BY DESC
clause.
When a BY or BY DESC clause is used with a LIST statement, ENFORM prints only the
first instance of a grouped value in a report. When a BY or BY DESC clause is used
with a FIND statement, ENFORM writes all of the values of a grouped value to the
physical output file or transmits all of the values to the host language program.
Several clauses require that a field be grouped by a preceding BY or BY DESC clause.
Refer to the CUM, PCT, SUBTOTAL, AFTER CHANGE and BEFORE CHANGE
clauses in this section and Target Aggregates in Section 3.