当Cypher中的数组元素大于零时,如何计数?
With [12,-9,30,-5,4]
作为冲锋我会3,我该怎么办?
答案 0 :(得分:2)
类似这样的东西...
WITH [12,-9,30,-5,4] AS coll
RETURN filter(x IN coll WHERE x > 0) AS pos
,如果您需要实际的正数
WITH [12,-9,30,-5,4] AS coll
RETURN size(filter(x IN coll WHERE x > 0)) AS pos
正如@christophewillemsen所说
WITH [12,-9,30,-5,4] AS coll
RETURN size([x IN coll WHERE x > 0]) AS pos
答案 1 :(得分:0)
谢谢你我这样做,结果是正确的:
WITH [12,-9,30,-5,4] AS coll
RETURN size(filter(x IN coll WHERE x > 0)) AS pos