A .sum( x )

Read(190) Label: compute, sequence, sum,

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:

  A.sum()