Reputation: 51
I need to retrieve all relationships between 2 nodes grouped and I currently have this code, but the issue is I get multiple rows for each pair
MATCH (n)-[r]->(m)
WHERE n.name = '${query}' or
m.name = '${query}'
RETURN n, m, COUNT(r.aa) as aa, COUNT(r.bb) as bb
For example if I have x-aa[1,2,3]->y and x-bb[1,2,3]->y I will get 2 rows
x, y, 3, 0
x, y, 0, 3
and what I want is to get 1 row with the combination of the 2
x, y, 3, 3
Upvotes: 1
Views: 169
Reputation: 66999
Since your RETURN
clause uses the aggregation function COUNT
, it should return a single row for each pair of n
and m
nodes. Therefore, I suspect your query actually matches 2 different pairs, not a single pair.
Upvotes: 1