The group processing function allows you to summarize data from
existing database records.
You can specify:
- The grouping fields
- Selection values both before and after grouping
- A keyed sequence access path over the new records
- Mapped field definitions that allow you to do such functions as sum, average,
standard deviation, and variance, as well as counting the records in each
group
- The sort sequence and language identifier that supply the weights by which
the field values are grouped
You normally start by creating a file with a record format containing only
the following types of fields:
- Grouping fields. Specified on the GRPFLD parameter that define groups.
Each group contains a constant set of values for all grouping fields. The
grouping fields do not need to appear in the record format identified on the
FORMAT parameter.
- Aggregate fields. Defined by using the MAPFLD parameter with one or more
of the following built-in functions:
- %COUNT
- Counts the records in a group
- %SUM
- A sum of the values of a field over the group
- %AVG
- Arithmetic average (mean) of a field, over the group
- %MAX
- Maximum value in the group for the field
- %MIN
- Minimum value in the group for the field
- %STDDEV
- Standard deviation of a field, over the group
- %VAR
- Variance of a field, over the group
- Constant fields. Allow constants to be placed in field values. The
restriction that the Open Query File (OPNQRYF) command must know all fields
in the output format is also true for the grouping function.
When you use group processing, you can only read the file sequentially.