• esProc
Tutorial
Function Reference
User Reference
External Library Guide
Data File Tool Manual
DQL Tutorial
Cluster Server Manager Manual
SPL WIN Manual
• YModel
User Reference
JSON-style Parameter Guide
• ReportLite
User Reference
• Official Website

# avg()

Here’s how to use avg() functions.

## avg()

Description:

Compute average of members of a sequence.

Syntax:

 A.avg(x) avg(x1,…,xn) Equivalent to A.avg(), where x1,…,xn are members of sequence A

Note:

The function computes x with each member of sequence A and returns average value of the non-null members, during which non-numeric members are ignored. When non-null, numeric members are zero, the average is null.

Parameter:

 A A sequence x An expression; cannot be omitted when sequence A is a record sequence or a table sequence

Return value:

Numerical value

Example:

When A is a sequence:

 A 1 =[1,3,5,6].avg() 3.75. 2 =[2,null,4,3].avg() 3.0. 3 =[null,,"" ,"abc"].avg() Null. 4 =[2,4,3,"aaa"].avg() 3.0; ignore non-numeric members. 5 =[1,2,3,4].avg(~*~) 7.5; first compute the expression and then the average. 6 =avg(1,3,5,6) 3.75, which is same as A1.

When A is a table sequence or record sequence:

 A 1 =demo.query("select * from EMPLOYEE") 2 =A1.avg(SALARY) Compute average of non-null SALARY values. 3 =A1.(SALARY+100).avg() Add 100 to each SALARY value and then compute their average.