Enform Plus Reference Manual
Enform Plus Language Elements
Enform Plus Reference Manual—422684-001
3-16
Target Aggregates
The query groups target-item-1 and target-item-2 within by-item-2. The
aggregate AVG is used and the average value of target-item-2 is found by totaling
all of the values of target-item-2 and dividing that total by the number of
target-item-2 values. Notice that AVG target-item-2 prints as a separate
column on the report with only one nonblank entry. This entry corresponds to the
aggregate value of all records in the report.
When a target aggregate is specified in a FIND statement with OVER ALL either present
or used by default, only the first target-record contains the aggregate value. This field is
blank in all other target-records generated by the FIND statement.
Target Aggregate With OVER Syntax
If you specify a target aggregate in a LIST or FIND statement with the OVER syntax, a
single aggregated value is returned for each grouped value. Consider the query outline
and output diagram shown in Figure 3-4
.
In this example, AVG target-item-1 prints as a separate report column with a
nonblank entry only on the first line of each new by-item-2 group. This entry
represents the average of target-item-1 over the by-item-2 group.
When a target aggregate is specified in a FIND statement with the OVER syntax, the
aggregate value is present only in the first target-record for a by-item. This field is blank
for all other target-records.
Figure 3-4. Query Outline of Target-Aggregate With OVER Syntax
Query Outline:
LIST BY by-item-1,
BY by-item-2,
target-item-1
AVG(target-item-1 OVER by-item-2);
Output Diagram:
|---------|
by-item-1 by-item-2 | target- | AVG
| item-1 | target-item-1
--------- --------- |---------| -------------
xxxxxxx xxxxxxx | xxxxxxx | xxxxxxxxxxxxx
| xxxxxxx | (total/4)
| xxxxxxx |
| xxxxxxx |
|---------|
xxxxxxx | xxxxxxx | xxxxxxxxxxxxx
| xxxxxxx | (total/2)
|---------|
xxxxxxx xxxxxxx | xxxxxxx | xxxxxxxxxxxxx
| xxxxxxx | (total/3)
| xxxxxxx |
|---------|