I have tried the following query to get total score (score is in array of string like ("5","2")) as sum of home score and away score game.
match (e:Epl), (e1:Epl)
where ((e)-[:AWAY]->(e1) or (e1)-[:HOME]->(e)) and e.home=e1.away
return e.home,e1.away,
sum(toInteger(e.score[0])+ toInteger(e1.score[1])) as totalScore
I do have the relationship between two nodes as below: enter image description here
I want to calculate total score for each team (sum of home score and away score)
As an optimisation (to avoid creating a Cartesian product), it's beneficial to specify the
-[:AWAY|HOME]-
relationship, which allows eitherAWAY
orHOME
types in any direction. TheWHERE
clause then takes care of checking the direction of the relationship.