z/OS DFSORT: Getting Started
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Summing records

z/OS DFSORT: Getting Started
SC23-6880-00

Suppose that the English department wants to know the total price of books for all its courses. You can include just the records for the English department by using the INCLUDE statement, and add the book prices together by using the SORT and SUM statements.

On the SUM control statement, you specify one or more numeric fields that are to be summed whenever records have equally collating control fields (control fields are specified on the SORT statement). The data formats you can specify on the SUM statement are binary (BI), fixed-point (FI), packed decimal (PD), zoned decimal (ZD) and floating-point (FL).

To sum the prices for just the records for the English department, specify the price field on the SUM statement and the department field on the SORT statement. The INCLUDE statement selects just the records for the English department before SUM and SORT are processed, making the department field equal for all of the included records, and allowing the prices to be summed. (For a flowchart showing the order in which the INCLUDE, SUM, and SORT statements are processed, see Processing order of control statements.)

When you sum records, keep in mind that two types of fields are involved:
Control fields
specified on the SORT statement
Summary fields
specified on the SUM statement

The contents of the summary fields are summed for groups of records with the same control fields (often called "duplicate" records).

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014