2016-06-24 5 views
1

複数のノードのカウントを取得する方法。サイファークエリで関係のない複数のノードの数を取得する

MATCH (n1:node1) 
MATCH (n2:node2) 
MATCH (n3:node3) where n3.status = "active" 
return count(n1) as countOfNode1, 
count(n2) as countOfNode2, 
count(n3) as countOfNode3 

実際のカウントがこれを行うにはどのように

countOfNode1 = 0 
countOfNode2 = 3 
countOfNode3 = 1 

ここでこのクエリは

countOfNode1 = 0 
countOfNode2 = 0 
countOfNode3 = 0 

として重複した結果を返していますか?

「distinct」を使用しても問題は解決しません。 として考える:私は考えている

return count(distinct n1) as countOfNode1, 
count(distinct n2) as countOfNode2, 
count(distinct n3) as countOfNode3 
+0

であるあなたは、ノードがどのrelationship'を持っていない '何を意味するのですか?どこのノード間のクエリの関係ですか? –

+0

ノードn1とn2は関連していません – Jeevika

+0

私の答えは機能しましたか? –

答えて

0

一つの可能​​性は、この

MATCH (n1:node1) WITH count(n1) as countOfNode1 
MATCH (n2:node2) WITH count(n2) as countOfNode2 
MATCH (n3:node3) where n3.status = "active" WITH count(n3) as countOfNode3 
return countOfNode1, 
countOfNode2, 
countOfNode3 

それとも

MATCH (n1:node1), (n2:node2),(n3:node3 {status:"active"}) 
return count(n1) as countOfNode1, 
count(n2) as countOfNode2, 
count(n3) as countOfNode3 
関連する問題