apoc.coll.runningTotal
Syntax |
|
||
Description |
Returns an accumulative |
||
Arguments |
Name |
Type |
Description |
|
|
The list to return a running total from. |
|
Returns |
|
Usage examples
The following examples return a list containing the running total of all previous values using both APOC and Cypher:
apoc.coll.runningTotal
WITH [1,3,5,7,9] AS list
RETURN apoc.coll.runningTotal(list) AS output
Using Cypher’s reduce()
WITH [1,3,5,7,9] AS list
RETURN reduce(cumL = [head(list)], x IN tail(list) | cumL + (last(cumL) + x)) AS output
output |
---|
[1, 4, 9, 16, 25] |