Skip to main content

Celonis Product Documentation

AVG
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 always a FLOAT.

Syntax
 AVG ( table.column )
NULL handling

NULL values are ignored, so they do not influence the result. If all the values of a group are NULL, the result for this group is also NULL.

Use Cases
Examples

[1]

Calculating the average of four small integers:

Query

Column1

         AVG ( "Table1"."Column" )
        

Input

Output

Table1

Column : int

-1

1

3

7

Result

Column1 : float

2.5

[2]

Calculating the average of values grouped by country:

Query

Column1

         "Table1"."Country"
        

Column2

         AVG ( "Table1"."Values" )
        

Input

Output

Table1

Country : string

Values : int

'DE'

10

'US'

2

'FR'

10

'DE'

3

'US'

40

'DE'

5

'US'

3

Result

Column1 : string

Column2 : float

'DE'

6.0

'FR'

10.0

'US'

15.0

[3]

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

Query

Column1

         "Table1"."Country"
        

Column2

         AVG ( "Table1"."Values" )
        

Input

Output

Table1

Country : string

Values : int

'FR'

10

'FR'

null

'DE'

null

Result

Column1 : string

Column2 : float

'DE'

null

'FR'

10.0

See also: