Enform Plus Reference Manual
Enform Plus Language Elements
Enform Plus Reference Manual—422684-001
3-13
Predefined Aggregates
UNIQUE
excludes duplicate values from contributing to the collecting operation of the 
aggregate. UNIQUE adds considerable processing overhead and should not be 
specified unless you know unwanted duplicate values exist. UNIQUE is redundant 
with MAX or MIN. While the same answer is returned when UNIQUE is specified 
with these aggregates, processing time increases greatly.
Predefined Aggregates
The five predefined Enform Plus aggregates are: AVG, COUNT, MAX, MIN, and SUM.
AVG finds an average value for a set of numbers. For each record containing a field value 
to be averaged, the field value is added to the running total of the contributing field 
values. After all contributing field values are processed, the final total is divided by the 
number of field values that made up the total. The following example finds the average 
of the partcost field over the suppnum field:
LIST BY suppnum,
 AVG(partcost OVER suppnum);
COUNT tallies the instances of an element. In the following example, the number of parts 
kept in stock are counted by counting the part numbers in parts:
OPEN parts;
LIST COUNT(partnum);
MIN determines the lowest number in a set of numbers or expressions. MAX determines 
the highest number in a set of numbers or expressions. The following example finds both 
the lowest and the highest price of a part:
OPEN fromsup;
LIST BY partnum,
 MIN(partcost OVER partnum),
 MAX(partcost OVER partnum);
SUM totals a set of numbers or expression values. In the following example, the sum of 
the sales made by each salesman is obtained:
OPEN order,odetail,parts;
LINK order to odetail VIA ordernum;
LINK odetail to parts VIA partnum;
LIST BY salesman,
 SUM (price * quantity) OVER salesman);
User Aggregates
When the predefined aggregates do not meet your needs, you can define your own 
aggregates with a DECLARE statement. A user-defined aggregate can be used anywhere 
a predefined aggregate can appear with two exceptions:










