How about something like this? WITH [100, 100, 100, 200, 300, 500] AS allShares UNWIND RANGE(0, LENGTH(allShares)-1) AS idx RETURN allShares[idx], REDUCE(acc = 0, value in (allShares[idx] + allShares[..idx]) | acc + value) AS cumulative
- ==> +-----------------------------+ - ==> | allShares[idx] | cumulative | - ==> +-----------------------------+ - ==> | 100 | 100 | - ==> | 100 | 200 | - ==> | 100 | 300 | - ==> | 200 | 500 | - ==> | 300 | 800 | - ==> | 500 | 1300 | - ==> +-----------------------------+ - ==> 6 rows On 2 August 2015 at 13:11, Ryan Elfman <[email protected]> wrote: > Hello, > > I'm trying to calculate a running sum using REDUCE however it bundles it > up as one record. Is it possible to return something like: > > shares total > 100 100 > 100 200 > 100 300 > > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
