Here’s how to use sum() function.
Description:
Compute x with each member of the sequence and compute the sum of the members of the new sequence.
Syntax:
A.sum(x) |
Equivalent to A.(x).sum() |
Note:
The function loops through members of sequence A to compute expression x and returns the sum of members of the resulting sequence.
Parameters:
A |
A sequence |
x |
Generally an expression of a single field name, or a legal expression composed of multiple field names. The computed result of the expression is numeric data type. |
Return value:
A numeric value
Special Note:
Take a null value as zero
Example:
|
A |
|
1 |
=demo.query("select * from EMPLOYEE") |
|
2 |
=A1.sum(SALARY) |
Sum up the salaries of all employees |
3 |
=A1.(SALARY+100).sum() |
Add 100 to the salary of each employee and then sum up all the employees’ salaries |
Related functions:
Description:
Compute the sum of members of a sequence.
Syntax:
A.sum() |
Equivalent to sum(x1,…,xn) |
Note:
The function computes the sum of members in sequence A; skip those members that are not numerical values.
Parameters:
A |
A sequence |
Return value:
The sum of all members in sequence A
Special Note:
Take a null value as zero
Example:
|
A |
|
1 |
=[1,2,3,4].sum() |
10 |
2 |
=[2,null,3,4].sum() |
9 Take the null value as zero |
3 |
=[2, 3,4,"2323ads"].sum() |
9 Ignore the non-numerical members
|
4 |
=sum(1,2,3,4) |
10 |
Related functions: