Reputation: 305
I want to create a query in cypher but I have problems with one part this is how it should look
Upvotes: 0
Views: 40
Reputation: 66989
The aggregating function COUNT
should help. Something like this:
MATCH (t1:Thread)<-[:USED]-(u:User)-[:USED]->(t2:Thread)
WHERE t1.id = 123
RETURN t1, t2, COUNT(DISTINCT u) AS cnt
ORDER BY cnt DESC
The DISTINCT
option, which incurs overhead, should only be used if it is possible for a User
to be related to the same pair of threads multiple times.
Upvotes: 1