Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ Returns the sum of a list of numbers.

Null elements are skipped. A non-numeric element raises an error.

*APOC Compatible:* `apoc.coll.sum`
*APOC Compatible:* `apoc.coll.sum`. Called under the `apoc.` name, the sum of an empty list is null, as in APOC (`apoc.coll.avg`, `apoc.coll.max` and `apoc.coll.min` answer null for an empty list too), while `coll.sum([])` keeps answering `0.0`.

[source,cypher]
----
Expand All @@ -346,6 +346,9 @@ RETURN coll.sum([1, 2, 3, 4]) AS result
RETURN coll.sum([]) AS result
// Returns: 0.0

RETURN apoc.coll.sum([]) AS result
// Returns: null

RETURN coll.sum([1, 2, 'x']) AS result
// Error: Type mismatch: coll.sum() expects an INTEGER or a FLOAT argument but got STRING
----
Expand Down
Loading