SUM(recordset, value, [ , expression ] [, KEYED ])
SUM( valuelist [, UNORDERED | ORDERED( bool ) ] [, STABLE | UNSTABLE ] [, PARALLEL [ ( numthreads ) ] ] [, ALGORITHM( name ) ] )
| recordset | The set of records to process. This may be the name of a dataset or a record set derived from some filter condition, or any expression that results in a derived record set. This also may be the keyword GROUP to indicate finding the sum of values of the field in a group, when used in a RECORD structure to generate crosstab statistics. | 
| value | The expression to sum. | 
| expression | Optional. A logical expression indicating which records to include in the sum. Valid only when the recordset parameter is the keyword GROUP to indicate summing the elements in a group. | 
| KEYED | Optional. Specifies the activity is part of an index read operation, which allows the optimizer to generate optimal code for the operation. | 
| valuelist | A comma-delimited list of expressions to find the sum of. This may also be a SET of values. | 
| UNORDERED | Optional. Specifies the output record order is not significant. | 
| ORDERED | Specifies the significance of the output record order. | 
| bool | When False, specifies the output record order is not significant. When True, specifies the default output record order. | 
| STABLE | Optional. Specifies the input record order is significant. | 
| UNSTABLE | Optional. Specifies the input record order is not significant. | 
| PARALLEL | Optional. Try to evaluate this activity in parallel. | 
| numthreads | Optional. Try to evaluate this activity using numthreads threads. | 
| ALGORITHM | Optional. Override the algorithm used for this activity. | 
| name | The algorithm to use for this activity. Must be from the list of supported algorithms for the SORT function's STABLE and UNSTABLE options. | 
| Return: | SUM returns a single value. | 
The SUM function returns the additive sum of the value in each record of the recordset or valuelist.
Example:
personRecord := RECORD
  STRING UID;
  STRING first_name;
  STRING last_name;
  INTEGER hourly_wage;  
END;
person := DATASET([{'923','James','Jones',15},
                   {'924','Sally','Jones',15},
                   {'925','Jose','Gomez',17},
                   {'926','Adam','Wesson',77},
                   {'927','Evelyn','Murray',74},
                   {'928','Tom','Murray',74},
                   {'929','Joe','Yung',75}], personRecord);
SumOfHourlyWage := SUM(person,person.hourly_wage); // total all hourly wage values
OUTPUT(SumOfHourlyWage);
SumVal1 := SUM(4,8,16,2,1); //returns 31
SetVals := [4,8,16,2,1];
SumVal2 := SUM(SetVals); //returns 31
OUTPUT(SumVal1);
OUTPUT(SumVal2);