Aggregate Report Functions

Each aggregate report function of 4GL returns a value summarizing data from all the input records, or from a specified group of input records. The 4GL report aggregates are not valid outside of a REPORT program block.

4GLREF00000024.gif

The 4GL report aggregates resemble the SQL aggregates that can appear in SELECT or DELETE statements, but their syntax is not identical. Aggregate report functions cannot appear as operands of 4GL expressions, and cannot be nested. That is, no expression within a report aggregate can include a report aggregate.

Their names are reserved words of 4GL. Other functions that you define to calculate the same statistics can be invoked from within or outside of REPORT definitions, but you must declare other names for such functions.

Variables of large or structured data types cannot be arguments to these functions. You can, however, specify the name of a simple variable that is a member of a record, or that is an element of an array.

AVG( ), SUM( ), MIN( ), and MAX( ) ignore records with NULL values for their argument, but each returns NULL if all records have a NULL value.

If an aggregate value that depends on all records of the report appears anywhere except in the ON LAST ROW control block, then each variable in that aggregate or WHERE clause must also appear in the list of formal arguments of the report. (Examples of aggregates that depend on all records include using GROUP COUNT(*) anywhere in a report, or using any aggregate without the GROUP keyword anywhere outside the ON LAST ROW control block.)

4GL stores intermediate results for aggregates in temporary tables. An error results if no database is open, because the temporary table cannot be created.

References

LINENO

PAGENO

WORDWRAP