Reputation: 1028
I have this kinds of relationships:
(:User)<-[:MENTIONS]-(:Tweet)-[:ABOUT]->(:Topic)
I would like to count all the users mentioned in the tweets regarding some topic.
With the following query
match (n:Topic)<--(t:Tweet)-[:MENTIONS]->(u:User)
where n.name='politics'
return distinct count(u)
all I get is the relationships count.
What I would like to get is, instead, the number of users mentioned (without duplicates if a user is mentioned several times). How is that possible?
Upvotes: 13
Views: 16153
Reputation: 16355
Try putting distinct inside count
function, this way:
match (n:Topic)<-[:ABOUT]-(t:Tweet)-[:MENTIONS]->(u:User)
where n.name='politics'
return count(distinct u)
Upvotes: 21