Description
In general, only one aggregation is calculated for a query. With a global aggregation it is possible to calculate an additional aggregation function over all values of a column.
GLOBAL calculates an aggregation function for an aggregation to which all values are aggregated into one group.
Like normal aggregations, a global aggregation function take filters and selections into account. Values which are filtered out are not part of the result. Therefore if a filter or a selection is changed, every global aggregation function is recalculated.
Syntax
GLOBAL ( aggregation )
- aggregation: The
aggregation function including
its parameters to use. Can be one of:
- AVG ( table.column )
- COUNT ( DISTINCT table.column )
- COUNT_TABLE ( table.column )
- COUNT ( table.column )
- MAX ( table.column )
- MEDIAN ( table.column )
- MIN ( table.column )
- QUANTILE ( table.column, quantile )
- STDEV ( table.column )
- SUM ( table.column )
- TRIMMED_MEAN ( table.column )
- VAR ( table.column )
NULL handling
If the input value is NULL, then GLOBAL returns NULL as well.
Note
The result of GLOBAL can not be used as a grouper column for an aggregation.
Like the standard aggregation functions, GLOBAL can not be used inside a FILTER statement.
Examples
Filter
FILTER "Table1"."Dimension" != 'C';
Column1
"Table1"."Dimension"
Column2
SUM ( "Table1"."Value" ) / GLOBAL ( COUNT ( "Table1"."Value" ) )
Column1
"Table1"."Dimension"
Column2
CASE WHEN "Table1"."Value" > GLOBAL ( AVG ( "Table1"."Value" ) ) THEN 1 ELSE 0 END