As union doesn't support global aggregation, ordering etc yet, perhaps
something like this:


MATCH (n:USER{id:'1'})
WITH n
MATCH (n)- [:LOCATED_IN]-> () <-[:LOCATED_IN]-(m1)
WITH n, collect(distinct m1.name) AS names
MATCH (n) - [:TEXTED]->(m2)
WHERE m2.name not in names
WITH n, collect(distinct m2.name) + names as names
MATCH (n) <- [:EMAILED]-(m3)
WHERE m3.name not in names
RETURN count(distinct m3.name) + length(names)



On Mon, Apr 21, 2014 at 5:17 PM, Alx <[email protected]> wrote:

> This is probably kind of a newbie's question but I have 3 multiple MATCH
> queries that each return separate results. I want to consolidate/combine
> them and count the distinct values.
>
> Here is an example
>
> MATCH (n:USER{id:'1'}) - [:LOCATED_IN]-> () <-[:LOCATED_IN]-(m1) WITH n,
> m1.name AS group1
> MATCH (n:USER{id:'1'}) - [:TEXTED]->(m2) WITH n, m2.name AS group2
> MATCH (n:USER{id:'1'}) <- [:EMAILED]-(m3) WITH n, m3.name AS group3
>
> So basically I want to count the distinct values in group1, group2 and
> group3 combined.
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to