Santi Barbat
Santi Barbat

Reputation: 2325

Sum two properties of the same node in Cypher

I can sum a property of all the node given from a cypher query. But ¿is it posible to sum two properties of the same node?

Example: MATCH (n: Node) WITH n.a + n.b as sum RETURN sum

UPDATE: Resolve in other comments, but if you want to get a sum of multiple properties of all nodes you can do:

MATCH (n:Node)
WITH sum(n.a + n.b) AS sum
RETURN sum

Upvotes: 1

Views: 670

Answers (1)

Nicole White
Nicole White

Reputation: 7800

Yes, you can. In your example you could just do

MATCH (n:Node) RETURN n.a + n.b AS sum

http://console.neo4j.org/r/dqq2cx

Upvotes: 2

Related Questions