Specifying the aggregate shown in Figure 3-3 is the same as specifying:
AVG(target-item-2);
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
non-blank 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 assumed, 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.
Figure 3-4. Query Outline of Target-Aggregate with OVER Syntax
Query outline:
LIST BY by-item-1,
Output Diagram:
by-item-1
---------
xxxxxxx
xxxxxxx
058057 Tandem Computers Incorporated
BY by-item-2,
target-item-1
AVG(target-item-1 OVER by-item-2);
|---------|
by-item-2
| target- |
| item-1
---------
|---------|
xxxxxxx
| xxxxxxx |
| xxxxxxx |
| xxxxxxx |
| xxxxxxx |
|---------|
xxxxxxx
| xxxxxxx |
| xxxxxxx |
|---------|
xxxxxxx
| xxxxxxx |
| xxxxxxx |
| xxxxxxx |
|---------|
ENFORM Language Elements
Aggregates
AVG
|
target-item-1
-------------
xxxxxxxxxxxxx
(total/4)
xxxxxxxxxxxxx
(total/2)
xxxxxxxxxxxxx
(total/3)
3–17