2

次の例でパーセンテージを見つけようとしています

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

私はこのようなものを得ることを望んでいました

Frequency        Sum
12               19
6                19
1                19

など。

私が得るのは、頻度列と合計列で同じ値です

 Frequency        Sum
    12               12
    6                6
    1                1

正しい分布を取得する方法はありますか? 私の最終的な目標は、行を返すリーチの頻度/合計を割ってパーセンテージを見つけることです。ありがとう

4

2 に答える 2

6

これはどうですか(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
于 2013-07-30T14:22:53.737 に答える