Skip to Content
Cypher ManualExpressionAggregate Functions

Aggregate Function

Aggregate Functions are primarily used to group current data and perform aggregation operations on elements within each group, ultimately producing only a single value for each group. The Aggregate Functions supported by NeuG are as follows:

FunctionDescriptionCan be used with DISTINCTExample
countreturn the row countsYESRETURN count(a.name);
collectcollect the elements in a single listYESRETURN collect(a.name);
minreturn the minimum valueNORETURN min(a.age);
maxreturn the maximum valueNORETURN max(a.age);
sumsum up the valueNORETURN sum(a.age);
avgreturn the average valueNORETURN avg(a.age);

NULL Value Handling

  • When the input is empty, count() and sum return 0, collect returns [], and avg, min, and max return NULL.
  • When the input contains NULL values, all aggregate functions ignore them. In particular, count(*) counts every input row, including rows containing NULL values.
  • When the input consists entirely of NULL values, the aggregate results after ignoring NULL are the same as for empty input: count() and sum return 0, collect returns [], and avg, min, and max return NULL. count(*) still returns the total number of input rows.
Inputcount(expr)count(*)collectminmaxsumavg
[]00[]NULLNULL0NULL
[1, NULL, 2]23[1, 2]1231.5
[NULL, NULL]02[]NULLNULL0NULL
Last updated on