Aggregation functions

EQL supports the following aggregation functions.

Function Description
ARB Selects an arbitrary but consistent value from the set of values in a field. Works on both multi-assign attributes (sets) and single-assign attributes.
AVG Computes the arithmetic mean value for a field.
COUNT Counts the number of records with valid non-NULL values in a field for each GROUP BY result. Works on both multi-assign attributes (sets) and single-assign attributes.
COUNTDISTINCT Counts the number of unique, valid non-NULL values in a field for each GROUP BY result. Works on both multi-assign attributes (sets) and single-assign attributes.
MAX Finds the maximum value for a field.
MIN Finds the minimum value for a field.
MEDIAN Finds the median value for a field. (Note that PAGE PERCENT provides overlapping functionality). If the argument is an integer, a double is always returned.
Note that the EQL definition of MEDIAN is the same as the normal statistical definition when EQL is computing the median of an even number of numbers. That is, given an input relation containing {1,2,3,4}, the following query:
RETURN results AS SELECT
  MEDIAN(a) AS med
GROUP
produces the mean of the two elements in the middle of the sorted set, or 2.5.
STDDEV Computes the standard deviation for a field.
STRING_JOIN Creates a single string containing all the values of a string attribute.
SUM Computes the sum of field values.
VARIANCE Computes the variance (that is, the square of the standard deviation) for a field.

STRING_JOIN function

The STRING_JOIN function takes a string property and a delimiter and creates a single string containing all of the property's values, separated by the delimiter. Its syntax is:
STRING_JOIN('delimiter', string_attribute)

The delimiter is a string literal enclosed in single quotation marks.

The resulting strings are sorted in an arbitrary but stable order within each group. NULL values are ignored in the output, but values having the empty string are not.

For this sample query, assume that the R_NAME standard attribute is of type string and contains names of regions, while the R_NAME standard attribute is also of type string and contains the names of nations:
RETURN results AS SELECT
  STRING_JOIN(', ',R_NAME) AS Regions,
  STRING_JOIN(',',N_NAME) AS Nations
GROUP
The query will return the region and country names delimited by commas:
Nations
ALGERIA, ARGENTINA, BRAZIL, CANADA, CHINA, EGYPT, ETHIOPIA, FRANCE, GERMANY, INDIA, INDONESIA, IRAN,
IRAQ, JAPAN, JORDAN, KENYA, MOROCCO, MOZAMBIQUE, PERU, ROMANIA, RUSSIA, SAUDI ARABIA, UNITED KINGDOM,
UNITED STATES, VIETNAM
Regions
AFRICA,AMERICA,ASIA,EUROPE,MIDDLE EAST

Note that the Regions delimiter includes a space while the Nations delimiter does not. That is, if you want a space between the output terms, you must specify it in the delimiter.