Syntax of Aggregates
The basic syntax of an aggregate specification is:
[cumulative|cum [(breakname)]] aggname
(columnname [, preset])
where:
breakname
Specifies the name of a break in the report (either a sort column name, or report or page ). It is optionally used as a parameter to the cumulative function to indicate when to reset the cumulative. The value of a cumulative represents the aggregate since the last break in breakname. The default value for breakname is report (that is, the value represents the cumulative value of an aggregate since the start of the report).
aggname
Specifies the name of the aggregation to be executed. Valid aggnames and synonyms are average (avg), decimal, count (cnt), minimum (min), maximum (max), and sum.
columnname
Specifies the column name in the data being reported. Values of this column are aggregated. Therefore, the column must be of the correct type (that is, numeric or date columns only for all aggregates except count). Note that a columnname must be specified for the count aggregate even though all columns result in the same value.
preset
Specifies either a constant value or the name of a column that is used for pre-setting the aggregate before calculations begin. This is used primarily with the cumulative function to set an aggregate to a non-zero value before starting.
For example, if to print an account balance next to each transaction in an account, use the cumulative sum aggregate with a preset to the starting balance of the account. For an example, see Account Example in the appendix "Report-Writer Report Examples." If preset is a constant, the aggregate is set to that value. It can be a numeric or date constant.
If preset is a valid numeric or date column name, the aggregate is set to the value in that column at the start of the break over which the aggregate is defined. In addition, preset is not allowed with the average aggregate.