I'm trying to return a relationship property (called proportion
) plus the sum of that property for all relationship matched by a Cypher query in Neo4j. I've gotten this far:
START alice=node(3)
MATCH p=(alice)<-[r:SUPPORTED_BY]-(n)
RETURN reduce(total=0, rel in relationships(p): total + rel.proportion), sum(r.proportion) AS total;
This returns:
+-----------------+
| reduced | total |
+-----------------+
| 2 | 2 |
| 1 | 1 |
+-----------------+
where I was expecting:
+-----------------+
| reduced | total |
+-----------------+
| 2 | 3 |
| 1 | 3 |
+-----------------+
As a beginner user of Cypher, I'm not really sure how to approach this query; I'm clearly not using reduce
correctly. Any advice would be appreciated.