0

我尝试了以下查询来获取总分(得分在字符串数组中,如 ("5","2"))作为主场得分和客场得分的总和。

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

我确实有两个节点之间的关系如下: 在此处输入图像描述

我想计算每支球队的总分(主客场得分之和)

4

1 回答 1

0

作为一种优化(避免创建笛卡尔积),指定-[:AWAY|HOME]-关系是有益的,它允许任何方向的AWAYor 或HOME类型。然后该WHERE子句负责检查关系的方向。

match (e:Epl)-[:AWAY|HOME]-(e1:Epl)
where ((e)-[:AWAY]->(e1) or (e1)-[:HOME]->(e))
  and e.home = e1.away
return
  sum(toInteger(e.score[0]) + toInteger(e1.score[1])) as totalScore
于 2018-01-07T09:25:10.263 回答