cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Right use of distinct with subquery

rob2
Node Clone

HI

I use the follwowing query

MATCH
((node_left: org)-[relationship_leftnode_currentstatus: current_status]->(node_currentstatus)),
((node_left)-[relationship_leftnode_hasmail: has_mail]->(node_mail))
CALL {
    WITH node_left
    MATCH ((node_left)-[relationship_leftnode_hasmail: has_mail]->(node_mail))
	WITH distinct node_mail LIMIT 10
    RETURN collect(node_mail.name) AS MailList
}
 RETURN 
 node_left.name AS LeftNode ,
 MailList,
 node_currentstatus.name AS CurrentStatus;

Unfortunately I get as result 2 times exact the seleceted row back ... Can anyone tell me how to use DISTINCT correctly?

│"LeftNode" │"MailList"                               │"CurrentStatus"│
│"_AdminOrg"│["admingroup@local","rootmessages@local"]│"active - Org" │
│"_AdminOrg"│["admingroup@local","rootmessages@local"]│"active - Org" │

Thanks rob

1 REPLY 1

rob2
Node Clone

Sorry i found it myself

MATCH
((node_left: org)-[relationship_leftnode_currentstatus: current_status]->(node_currentstatus))
CALL {
WITH node_left
MATCH ((node_left)-[relationship_leftnode_hasmail: has_mail]->(node_mail))
WITH distinct node_mail LIMIT 10
RETURN collect(node_mail.name) AS MailList
}
RETURN
node_left.name AS LeftNode ,
MailList,
node_currentstatus.name AS CurrentStatus;