apoc.coll.sumLongs

Details

Syntax

apoc.coll.sumLongs(coll)

Description

Returns the sum of all the INTEGER | FLOAT in the LIST<INTEGER | FLOAT>.

Arguments

Name

Type

Description

coll

LIST<INTEGER | FLOAT>

The list of numbers to create a sum from after each is cast to a java Long value.

Returns

INTEGER

Usage examples

The following examples compute the sum of numeric values in a list, casting them to Long (Cypher integer) values in the process, using both APOC and Cypher:

apoc.coll.sumLongs
WITH [1.5,2.5,3.6,4.3,5.2] AS list
RETURN apoc.coll.sumLongs(list) AS output
Using Cypher’s UNWIND, sum() and toInteger()
WITH [1.5,2.5,3.6,4.3,5.2] AS list
RETURN reduce(sum = 0, x IN toIntegerList(list) | sum + x) AS output
Results
Output

15