This page lists the aggregation functions available in the GSQL query language. These functions take a single SET
, BAG,
SetAccum
, BagAccum
, or ListAccum
as the parameter and return an aggregated value from all members of the set or bag.
The DISTINCT
keyword can be used to include repeated values only once when aggregating.
avg( [DISTINCT] setExp )
Returns the average of all elements in a set or bag. The function can only take set/bag expressions whose members are numeric types.
A numeric type. If all members of the set/bag expression are integers, the return value will also be rounded down to be an integer.
count( [DISTINCT] setExp )
Returns the size of the set or bag.
INT
max( [DISTINCT] setExp )
Returns the member with the maximum value in a set or bag. The function can only take set/bag expressions whose members are numeric types.
A numeric type.
min( [DISTINCT] setExp )
Returns the member with the minimum value in a set or bag. The function can only take set/bag expressions whose members are numeric types.
A numberic type.
sum( [DISTINCT] setExp )
Returns the sum of all members in a set or bag. The function can only take set/bag expressions whose members are numeric types.
A numeric type.
Parameter
Description
Data type
setExp
An expression that evaluates to a SET
, BAG
, SetAccum
, BagAccum
, ListAccum
SET
, BAG
, SetAccum
, BagAccum, ListAccum
Parameter
Description
Data type
setExp
An expression that evaluates to a SET
, BAG
, SetAccum
, BagAccum
, ListAccum
SET
, BAG
, SetAccum
, BagAccum, ListAccum
Parameter
Description
Data type
setExp
An expression that evaluates to a SET
, BAG
, SetAccum
, BagAccum
, ListAccum
SET
, BAG
, SetAccum
, BagAccum, ListAccum
Parameter
Description
Data type
setExp
An expression that evaluates to a SET
, BAG
, SetAccum
, BagAccum
, ListAccum
SET
, BAG
, SetAccum
, BagAccum, ListAccum
Parameter
Description
Data type
setExp
An expression that evaluates to a SET
, BAG
, SetAccum
, BagAccum
, ListAccum
SET
, BAG
, SetAccum
, BagAccum, ListAccum