Overview
An aggregate function performs a calculation on a set of values and returns a single scalar value.
DISTINCT
All aggregate functions support the use of the set quantifier DISTINCT
to deduplicate values before aggregation.
Null Values
Rows containing null
values are ignored by all aggregate functions.
Example Graph
The following examples run against this graph:
avg()
Computes the average of a set of numeric values.
Syntax | avg(<values>) |
||
Arguments | Name | Type | Description |
<values> |
Numeric | The target values | |
Return Type | DOUBLE |
find().nodes() as n
return avg(n.score)
Result:
avg(n.score) |
---|
7.33333333333333 |
collect()
Collects a set of values into a list.
Syntax | collect(<values>) |
||
Arguments | Name | Type | Description |
<values> |
Any | The target values | |
Return Type | LIST |
find().nodes() as n
return collect(n.title)
Result:
collect(n.title) |
---|
["Optimizing Queries","Efficient Graph Search","Path Patterns"] |
count()
Returns the number of records in the input.
Syntax | count(<values>) |
||
Arguments | Name | Type | Description |
<values> |
Any | The target values | |
Return Type | UINT |
find().nodes() as n
return count(n)
Result:
count(n) |
---|
3 |
uncollect [1, "a", "2", "b3", null] as item
return count(item)
Result:
count(item) |
---|
4 |
count(DISTINCT)
You can include the set quantifier DISTINCT
in count()
to return the number of distinct records in the input.
uncollect [1, 1, "a", "2", "b3", null] as item
return count(DISTINCT item)
Result:
count(DISTINCT item) |
---|
4 |
max()
Returns the maximum value in a set of values.
Syntax | max(<values>) |
||
Arguments | Name | Type | Description |
<values> |
Any | The target values | |
Return Type | Numeric |
find().nodes() as n
return max(n.score)
Result:
max(n.score) |
---|
9 |
uncollect [1, "a", "2.1", "b3"] as item
return max(item)
Result:
max(item) |
---|
2 |
min()
Returns the minimum value in a set of values.
Syntax | min(<values>) |
||
Arguments | Name | Type | Description |
<values> |
Any | The target values | |
Return Type | Numeric |
find().nodes() as n
return min(n.score)
Result:
min(n.score) |
---|
6 |
uncollect [1, "a", "2.1", "b3"] as item
return min(item)
Result:
min(item) |
---|
0 |
stddev_pop()
Computes the population standard deviation of a set of numeric values.
Syntax | stddev_pop(<values>) |
||
Arguments | Name | Type | Description |
<values> |
Numeric | The target values | |
Return Type | Numeric |
find().nodes() as n
return stddev_pop(n.score)
Result:
stddev_pop(n.score) |
---|
1.24721912892465 |
stddev_samp()
Computes the sample standard deviation of a set of numeric values.
Syntax | stddev_samp(<values>) |
||
Arguments | Name | Type | Description |
<values> |
Numeric | The target values | |
Return Type | DOUBLE |
find().nodes() as n
return stddev_samp(n.score)
Result:
stddev_samp(n.score) |
---|
1.52752523165195 |
sum()
Computes the sum of a set of values.
Syntax | sum(<values>) |
||
Arguments | Name | Type | Description |
<values> |
Numeric | The target values | |
Return Type | DOUBLE |
find().nodes() as n
return sum(n.score)
Result:
sum(n.score) |
---|
22 |