11. Report-Writer Expressions and Formats : Types of Data in Expressions : Aggregates
 
Share this page                  
Aggregates
You use an aggregate function, or set function, such as sum or count, to perform a calculation on data read in from one column, up to the occurrence of a break in another column. For instance, in the section, Population Example in the appendix, "Report-Writer Report Examples," the regional population subtotals represent use of the sum aggregate on each of the columns tot, tot_18 to 65, tot_under18, and tot_over65 up to a break in region. Additionally, the population totals at the end of the report represent use of the sum aggregate for the same columns up to a break in "report."
You specify which data must be used in the calculation by naming the column containing that data as a parameter of the aggregate function. In the POPULATION example, the columns containing the relevant data are tot, tot_18 to 65, tot_under18, and tot_over65. You indicate the cut-off point for the data to be included in each calculation by placing the aggregate function within the footer section for a particular column or section of the report. The aggregate value is calculated each time a break occurs in the specified footer.
Aggregates can be non-unique or unique, simple, or cumulative. A non-unique aggregate performs a calculation based on every value read in from the aggregate column up to a break in the specified footer. A unique aggregate performs a calculation on each break value in the aggregate column, up to a break in the specified footer. (Depending on how the data is sorted and where the aggregate is specified, the break values can or cannot be the actual unique values in a column.)
A simple aggregate produces a single value, calculated on all the values in the aggregate column up to a break in the specified footer. A cumulative aggregate calculates a running total for each value in the aggregate column up to the break containing the aggregate instruction. Simple and cumulative aggregates can be either non-unique or unique. Aggregate types are discussed in more detail later in this section.
The following aggregates are allowed:
avg
Finds the average value of a numeric column up to a break in the specified footer. You can take the average value of a date data type column that has date intervals. Taking an average of absolute dates generates a DBMS error.
avgu
Finds the average value of the unique or break values for a numeric column up to a break in the specified footer. You can specify avgu only for a break column. For additional details, see Unique Aggregates. You can take the average value of a date data type column that has date intervals. Taking an average of absolute dates generates a DBMS error.
count
Counts the number of rows up to a break in the specified footer.
countu
Counts the number of unique or break values up to a break in the specified footer. You can specify countu only for break columns. For more details, see Unique Aggregates.
min
Finds the minimum value of a numeric or date column up to a break in the specified footer.
max
Finds the maximum value of a numeric or date column up to a break in the specified footer.
sum
Calculates the sum of a numeric column up to a break in the specified footer. In columns of data type date, you can use the sum aggregate only if the column contains time intervals. Taking a sum on absolute dates generates a DBMS error.
sumu
Calculates the sum of the unique or break values in a numeric column up to a break in the specified footer. You can specify sumu only for break columns. For additional details, see Unique Aggregates. In columns of data type date, you can use the sumu aggregate only if the column contains time intervals. Taking a sum on absolute dates generates a DBMS error.