Progress
Language Reference


Aggregate Phrase

Interfaces
OS
SpeedScript
All
All
Yes

Identifies one or more values to calculate based on a change in an expression or a break group.

SYNTAX

{   AVERAGE
  | COUNT
  | MAXIMUM
  | MINIMUM
  | TOTAL
  | SUB-AVERAGE
  | SUB-COUNT
  | SUB-MAXIMUM
  | SUB-MINIMUM
  | SUB-TOTAL
} ... [ LABEL aggr-label ] [ BY break-group ] ... 

AVERAGE

Calculates the average of all of the values of the expression in a break group and the average of all of the values of the expression in all break groups.

COUNT

Calculates the number of times the expression was counted in a break group and the count of all the values in all break groups.

MAXIMUM

Calculates the maximum of all of the values of the expression in a break group and the maximum of all the values of the expression in all break groups.

MINIMUM

Calculates the minimum of all of the values of the expression in a break group and the minimum of all the values of the expression in all break groups.

TOTAL

Calculates the subtotal of all of the values of the expression in a break group and the grand total of all of the values of the expression in all break groups. When you use default aggregates, the actual display of the grand total is deferred until the frame goes out of scope.

SUB-AVERAGE

Averages values in a break group. Does not supply an average for all records, just for those in each break group.

SUB-COUNT

Counts the number of times an expression is in a break group. Does not supply a count for all records, just for those in each break group.

SUB-MAXIMUM

Shows the maximum value of an expression in a break group. Does not supply a maximum value for all records, just for those in each break group.

SUB-MINIMUM

Shows the minimum value of an expression in a break group. Does not supply a minimum value for all records, just for those in each break group.

SUB-TOTAL

Subtotals all of the values of the expression in a break group. Does not supply a total value for all records, just for those in each break group.

BY break-group

Performs aggregation for break groups if you use the BREAK option in a FOR EACH block header.

LABEL aggr-label

Specifies a label for the aggregate value. aggr-label is a standard Progress string and can use a string attribute. The string can be translated by Translation Manager II. You can specify a maximum length attribute that is greater than the length of the longest label translation.

EXAMPLES

This procedure lists the customer information for all customers (categorized by country) and a subtotal of each country’s balance. If you use TOTAL instead of SUB-TOTAL, Progress displays a grand total.

r-aggreg.p
FOR EACH customer BREAK BY country:
  DISPLAY name country balance (SUB-TOTAL BY country).
END. 

In the following procedure, Progress displays the result of the COUNT aggregate even though no accumulation has occurred. In this example, COUNT displays as 0.

r-agcnt.p
DEFINE VARIABLE prntr AS LOGICAL INITIAL FALSE.
FOR EACH item:
  IF prntr
  THEN DISPLAY item-name price(COUNT) WITH FRAME pr.
END. 

In the following procedure, Progress uses “Avg. Credit Limit” and “Max. Credit Limit” as the labels for the AVERAGE and MAXIMUM aggregates respectively.

r-aglim.p
FOR EACH customer:
  DISPLAY name credit-limit
    (AVERAGE LABEL "Avg. Credit Limit"
     MAXIMUM LABEL "Max. Credit Limit"
     TOTAL) WITH FRAME frame1 12 DOWN.
 END. 

NOTES

SEE ALSO

ACCUMULATE Statement, FOR Statement


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095