Applies to:  CELONIS 4.0 CELONIS 4.2 CELONIS 4.3 CELONIS 4.4 

Description

This aggregate function calculates the average of a set of values.

AVG calculates the average of an INT or FLOAT column. The data type of the result is the same as the data type of the input column.

Syntax

AVG ( table.column )

Null handling

Null values are ignored, meaning that they don't influence the result. If all values of a group are null, the result for this group is also null.

Tips

If the size of the source column greatly exceeds the number of aggregated groups, the average for each group will be executed in parallel. Therefore, to achieve a good performance, multiple CPU cores and balanced aggregation (as described) are preferable (Since:  CELONIS 4.3).

Examples

Calculating the average of four small integers:


Query
Column1
AVG ( "Table1"."Column" )
Input
Table1
Column : FLOAT
-1.0
1.0
3.0
7.0
Output
Result
Column1 : FLOAT
2.5




Calculating the average of values grouped by country:


Query
Column1
"Table1"."Country"
Column2
AVG ( "Table1"."Values" )
Input
Table1
Country : STRINGValues : INT
'DE'
10
'US'
2
'FR'
10
'DE'
3
'US'
40
'DE'
5
'US'
3
Output
Result
Column1 : STRINGColumn2 : INT
'DE'
6
'FR'
10
'US'
15




Calculating the average of values mixed with nulls, grouped by country:


Query
Column1
"Table1"."Country"
Column2
AVG ( "Table1"."Values" )
Input
Table1
Country : STRINGValues : INT
'FR'
10
'FR'
null
'DE'
null
Output
Result
Column1 : STRINGColumn2 : INT
'DE'
null
'FR'
10
  • No labels