#### Sum

- Sum(Number a[ ])
- Sum(Integer a[ ])
- Sum(Currency a[ ])
- Sum(DBField field)
- Sum(DBField, String groupby)

This function computes the sum of all the values referred to by the argument.

Parameters

- a - A Number, Integer or Currency array.
- field - Values of DBField or formula field.
- groupby - A constant string which indicates the DBField, formula or parameter grouped by.

Return value

The returned value type is dependent on the parameter. It can be Number, Integer or Currency.

Examples

- `Number x = Sum([1, 2, 3.0, 4.5, 45, 67])`
- `Number x[6] = [1, 2, 3.0, 4.5, 45, 67];
  Number y = Sum(x)`
- `Currency x = Sum([$1, $2, $3.0, $4.5, $45, $67])`
- `Currency x[] = [$1, $2, $3.0, $4.5, $45, $67];
  Currency y = Sum(x)`
- `Number x = Sum(@dbfield)`
- `Number x = Sum(@formula)`
- `Number x = Sum(@dbfield, @dbfield_groupby)`
- `Number x = Sum(@dbfield, @formula_groupby)`
- `Number x = Sum(@dbfield, @parameter)`
- `Currency x = Sum(@dbfield)`
- `Currency x = Sum(@formula)`
- `Currency x = Sum(@formula, @dbfield_groupby)`
- `Currency x = Sum(@formula, @formula_groupby)`
- `Currency x = Sum(@formula, @parameter)`

Note: If a field is assigned to a variable, for example x, the variable x will lose the characteristic of representing a group of values. So, the following formula will be treated as incorrect.

`Number x = @dbfield;
Number y = Sum( x); // system will prompt you that there is no such kind of function.`