hello guys I am new to cypher query and I want to restrict duplicate values in my result
the query is
match (ee:Personal {id:"id"})-[:Friend]->(fr),
(fr)-[:Friend]->(fr2),
(fr2)-[:Friend]->(friend:Personal),
(friend)-[:Works]->(comp:Company)
where comp.name=~".*name.*"
and not friend.id="id"
and not (friend)-[:Friend]-(fr)
and not (friend)-[:Friend]-(ee)
and not (fr2)-[:Friend]-(ee)
optional match (comp)-[:Position]->(pos),
(friend)-[:Position]->(pos)
optional match (friend)-[:Location]->(loc)
return distinct friend.name, comp.name
but i get duplicate values as there are multiple node properties in return statemnt. If I return only one property then its fine. but i want distinct friends
Distinct works on the whole row, if you want to return distinct friends per company, do:
return comp.name, collect(distinct friend.name)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With