sum of

Type

Relational Statistical Operator

Purpose

The sum of operator adds the values in a specified field in all matching records in a related table. The result can appear as a list item in the detail area of a report or as a statistic in the summary area at the end of each group or at the end of the report.

Syntax

sum of TABLENAME|RELATIONSHIP

 [named "UNIQUE RELATIONSHIP NAME" ]

 [with ( selection criteria) ] FIELDNAME ; | .

Returns

A numeric value.

Example

for MEMBERS ;

list records

LAST NAME in order ;

sum of RESERVATIONS TOTAL DUE .

end

 

This script tells DataEase: (1) Process all the MEMBERS records and list each member's LAST NAME in alphabetical order, (2) for each MEMBERS record processed, find all the related records in the RESERVATIONS table (those that have the same MEMBERID), and (3) list the sum of the TOTAL DUE field for the set of RESERVATIONS records that match the current MEMBERS record.

The output from this script might look as follows:

 

Last Name

Sum of Reservations

 

Total Due

Adams

$3000.00

Albert

$4760.00

Anders

$4420.00

Andersen

$2100.00

Anderson

$4320.00

Archer...

$4796.00...

 

If you want to include the sum of this whole group of reservations, change the fourth line of the query to read:

 

 sum of RESERVATIONS TOTAL DUE : item sum .

 

Note: There's an important difference between the statistical operator sum and the relational statistical operator sum of. sum returns the total of the values in the specified field among the records being processed. sum of returns the total of the values in the specified field among the records related to the records being processed.