I am using two conditions but once I am having the result displayed , there is only one condition executed

cypher
operations

(Mehdi Ajroud) #1

I am using this query and I used conditions to display only clusters which contains more than 3 contracts and 2 attributes but I am having a graph which contains clusters with only one contract .

match (n1:attribfxplaf)-[r]-(c:contratfxplaf)
with n1.clusterId as clusterId, count(n1) as attributaires, count(c) as contracts
where contracts > 3 and  attributaires > 2
match (n2) where n2.clusterId = clusterId
return n2,clusterId


(Andrew Bowman) #2

It's likely that the counts of contracts are counting the same node multiple times (the c is the same for nodes in that match with the same clusterId).

Try changing your query to count distinct nodes:

with n1.clusterId as clusterId, count(n1) as attributaires, count(DISTINCT c) as contracts

(Mehdi Ajroud) #3

I am getting the same results !


(Paul Thomas) #4

use this query to help debug the problem ...

match (n1:attribfxplaf)-[r]-(c:contratfxplaf)
return n1.clusterId as clusterId, count(n1) as attributaires, count(distcint c) as contracts
order by clusterId