我有这些标签:
现在我正在尝试此查询:
OPTIONAL MATCH
(pag:page),
(pag)-[:AUTHOR]-(pos:post),
(pos)-[:LIKED]-(likers:prof)
RETURN
pag.name,
count(pos) AS totalPagePosts,
sum(likers) AS totalPageLikes
然后我收到此错误:
File ":9:9": Type mismatch: expected Float or Integer but was Node (line 9, column 9)
"sum(likers) AS totalPageLikes"
我该如何进行此查询?
答案 0 :(得分:1)
请使用如下查询:
OPTIONAL MATCH
(pag:page),
(pag)-[:AUTHOR]-(pos:post),
(pos)-[:LIKED]-(likers:prof)
RETURN
pag.name,
count(distinct pos) AS totalPagePosts,
count(distinct likers) AS totalPageLikes
Sum()
是一个汇总函数,用于汇总数值,count()
只计算出现的次数。
请参阅Cypher Ref Card。