How Could I count array's elements when they are greater than zero in Cypher?
With [12,-9,30,-5,4]
as a resault I would 3, how could I do?
How Could I count array's elements when they are greater than zero in Cypher?
With [12,-9,30,-5,4]
as a resault I would 3, how could I do?
something like this...
WITH [12,-9,30,-5,4] AS coll
RETURN filter(x IN coll WHERE x > 0) AS pos
and if you wanted the actual number of positive numbers
WITH [12,-9,30,-5,4] AS coll
RETURN size(filter(x IN coll WHERE x > 0)) AS pos
and as @christophewillemsen says
WITH [12,-9,30,-5,4] AS coll
RETURN size([x IN coll WHERE x > 0]) AS pos
Thank you I did in this way and the result is correct:
WITH [12,-9,30,-5,4] AS coll
RETURN size(filter(x IN coll WHERE x > 0)) AS pos