我试图在以下示例中找到百分比
START n=node:name_idx(NAME="ABC")
match p = n-[r1:LIKES]->m
with r1.Frequency as Frequency, Sum(r1.Frequency) as Sum
return Frequency, Sum
Run Code Online (Sandbox Code Playgroud)
我希望得到这样的东西
Frequency Sum
12 19
6 19
1 19
Run Code Online (Sandbox Code Playgroud)
等等.
我得到的是Frequency和Sum列中的相同值
Frequency Sum
12 12
6 6
1 1
Run Code Online (Sandbox Code Playgroud)
有什么建议如何正确分配?我的最终目标是通过划分返回行的频率/总和来找出百分比.谢谢
这个怎么样(我偷了Luanne的控制台图):
http://console.neo4j.org/r/3axtkq
START n=node:node_auto_index(name="a")
MATCH n-[r1:LIKES]->m
WITH sum(r1.frequency) AS total, n // we want the total... of all frequencies for n
MATCH n-[r1:LIKES]->m // we need to get the likes again, because those can't be passed in with and get the total of all at the same time
RETURN r1.frequency, total, r1.frequency/(total*1.0) // it does integer math unless you force one to be a float
Run Code Online (Sandbox Code Playgroud)