Enform Plus Reference Manual
Enform Plus Language Elements
Enform Plus Reference Manual—422684-001
3-19
Aggregates and Scale
gives:
•
All employees whose salaries are less than the average
•
The average of all salaries that are less than the average
Qualification Aggregate With an Embedded WHERE Clause
If a qualification aggregate contains a WHERE clause that restricts the records for the
aggregate calculation, Enform Plus processes the embedded WHERE clause before the
aggregate. If any record for an over-item does not satisfy the restriction specified in the
embedded WHERE clause, Enform Plus excludes that record from the aggregate
calculation.
For example, consider Figure 3-6
, which shows an Enform Plus query containing a
qualification aggregate with a WHERE clause. The query prints the part number and the
amount in stock of all the parts where the price of the part is greater than the average
price of all parts not in stock.
Aggregates and Scale
All the aggregates except COUNT take their display format from the formats of the input
values. (COUNT always returns a value with a scale of zero, or no digits to the right of
the decimal point.) Consequently, if a field is defined as an integer and the aggregate
yields a fractional value, the aggregate returns only the whole portion of the value. If the
field is defined as a decimal, the value returned is accurate to the number of decimal
places provided by the DDL data definition for the field.
Figure 3-6. Qualification Aggregate With Embedded WHERE Clause
OPEN parts;
LIST partnum,
inventory,
WHERE price GT AVG (price WHERE inventory LT 0);
The report produced is:
Part Number INVENTORY
------------- -----------
212 7
244 3
1403 21
5502 6
5504 -1
5505 0
7102 20