Aggregation Usage Codes

Two types of aggregations are described here:

Table 14, following, shows which aggregation usage codes are valid when used with different data types.

Table 14. Valid Usage Codes for Data Types
Datatype Valid Usage Codes
Numeric AVG, COUNT, CPCT, CSUM, FIRST, LAST, MAX, MIN, PCT, STDEV, SUM, TCPCT, TPCT
Character, Date, Time, Timestamp COUNT, FIRST, LAST, MAX, MIN
Note
LONG VARCHAR and LONG VARGRAPHIC columns cannot be aggregated. The only valid usage codes for these data types are blank and OMIT.

Summarize Data in a Column

Reports: Aggregation usage codes summarize the data in a column. The results of an aggregation can appear in the middle of the report as subtotals or at the end of the report as totals.

AVERAGE
Average of the values in the column
COUNT
Count of the values in the column
FIRST
First value in the column
LAST
Last value in the column
MAXIMUM
Maximum value in the column
MINIMUM
Minimum value in the column
STDEV
Standard deviation of the values in the column
SUM
Sum of the values in the column

When you use MAXIMUM and MINIMUM on character, date, time, timestamp, or graphic data, QMF uses an EBCDIC collating sequence to compare the data. To determine MAXIMUM and MINIMUM for numeric data, QMF uses algebraic compares. Nulls can be included in the result for MAX, MIN, FIRST, and LAST.

A date/time function applied to a DATE, TIME, or TIMESTAMP value changes the data type of that value to numeric. Therefore, the resulting value can be aggregated.

The format of the result is determined by the edit code of the column, except for COUNT, STDEV, and percentage aggregations. COUNT can be applied to data of any type, but always produces an integer result; hence, its result is formatted with edit code K. STDEV, PCT, CPCT, TPCT, and TCPCT are formatted with edit code L. (See Edit Codes for Numeric Data.)

Charts: The information on reports for these usage codes is also true for charts.

AVERAGE, MAXIMUM, MINIMUM, STDEV, and SUM can all be useful in charting QMF data. Entries such as FIRST and LAST might not be useful in a chart format.

The following values are sent as null values to the ICU when you display a chart of the report:

Replace Data Value with a Calculation

Reports The following codes name aggregations that replace each detail line value in a column with a calculation and show a final result of the aggregation at the end of the report. They can also appear in the middle of the report as subtotals.

CSUM
The cumulative sum for each value in a column.
PCT
The percentage each value is of the total:

CPCT
The cumulative percentage for each value in a column:

TPCT
The total percentage each value is of the column total:

TCPCT
The total cumulative percentage for each value in a column:

These aggregations work only on numeric data. Nulls in the column are not included in the result, but undefined values and numeric overflow are evaluated. The format of the result is determined by the edit code of the column.

Four versions of a report follow. The only difference is a result of the aggregation specified on the form for the salary column.

Report 1:SUM SALARY (Total)

                                  SUM
           NAME       JOB        SALARY
           ---------  -----  ----------
           MOLINARE   MGR      22959.20
           LU         MGR      20010.00
           DANIELS    MGR      19260.25
           JONES      MGR      21234.00
                             ==========
                               83463.45

 

Report 2:CSUM SALARY (Cumulative Total)

                                   CSUM
            NAME       JOB        SALARY
            ---------  -----  ----------
            MOLINARE   MGR      22959.20
            LU         MGR      42969.20
            DANIELS    MGR      62229.45
            JONES      MGR      83463.45
                              ==========
                                83463.45

 

Report 3:PCT SALARY (Percentage)

                                  PCT
           NAME       JOB        SALARY
           ---------  -----  ----------
           MOLINARE   MGR         27.51
           LU         MGR         23.97
           DANIELS    MGR         23.08
           JONES      MGR         25.44
                             ==========
                                 100.00

 

Report 4:CPCT SALARY (Cumulative Percentage)

                                  CPCT
           NAME       JOB        SALARY
           ---------  -----  ----------
           MOLINARE   MGR         27.51
           LU         MGR         51.48
           DANIELS    MGR         74.56
           JONES      MGR        100.00
                             ==========
                                 100.00

Two versions of the same report with a break follow.

The first report uses PCT to show:

                               PCT
        JOB    NAME           SALARY
        -----  ---------  ----------
        CLERK  JAMES           25.71
               KERMISCH        23.34
               NGAN            23.81
               SNEIDER         27.14
                          ----------
                       *       41.61
 
        MGR    HANES           52.95
               SANDERS         47.05
                          ----------
                       *       30.91
 
        SALES  PERNAL          52.41
               ROTHMAN         47.59
                          ----------
                       *       27.47
 
                          ==========
                              100.00

This report uses TPCT to show:

                               TPCT
        JOB    NAME           SALARY
        -----  ---------  ----------
        CLERK  JAMES           10.70
               KERMISCH         9.71
               NGAN             9.91
               SNEIDER         11.29
                          ----------
                       *       41.61
 
        MGR    HANES           16.37
               SANDERS         14.54
                          ----------
                       *       30.91
 
        SALES  PERNAL          14.40
               ROTHMAN         13.08
                          ----------
                       *       27.47
 
                          ==========
                              100.00

Whenever you use a percentage usage code (PCT, CPCT, TPCT, and TCPCT), QMF shows the total percentage as 100. However, occasionally the individual percentages add up to a number slightly higher or lower than 100. That happens because QMF sometimes rounds off the individual percentages when it calculates them.

Charts:

The information on reports for these usage codes is also true for charts. Some of these codes might not be as meaningful in a chart as in a report:

[ Previous Page | Next Page | Contents | Index ]