cancel
Showing results for 
Search instead for 
Did you mean: 

Join the community at Nodes 2022, our free virtual event on November 16 - 17.

Nodes with duplicate property value

starz10de
Node Clone

I have a graph where each node contains two property A and B. I wanted to check e.g., if the same B value exist in other nodes (appear in the data more than one time). So far I succeed to find the occurrence of the property B value when its more than once in the data.

here is my code:

MATCH (n:data)
WITH n.b as b, COUNT(n) as count 
WHERE count>1
RETURN b, count

However, I want also to return a for each b that appears more than one time

1 ACCEPTED SOLUTION

bennu_neo
Neo4j
Neo4j

Hi @starz10de ,

Something like this should work

MATCH (n:data)
WITH n.b as b, collect(n) as li
WITH b, li
WHERE size(li)>1
RETURN b, li

Bennu

Oh, y’all wanted a twist, ey?

View solution in original post

2 REPLIES 2

bennu_neo
Neo4j
Neo4j

Hi @starz10de ,

Something like this should work

MATCH (n:data)
WITH n.b as b, collect(n) as li
WITH b, li
WHERE size(li)>1
RETURN b, li

Bennu

Oh, y’all wanted a twist, ey?

Thanks a lot, it works