I am using Neo4j 2.0 and using the following query to find out the count of number of a particular relationship from a particular node.
I have to check the number of relationships named "LIVES" from a particular node PERSON.
My query is:
match (p:PERSON)-[r:LIVES]->(u:CITY) where count(r)>1 return count(p);
The error shown is:
SyntaxException: Invalid use of aggregating function count(...)
How should I correct it?
Using count(*) to return the number of nodes. The function count(*) can be used to return the number of nodes; for example, the number of nodes connected to some node n . The labels and age property of the start node n and the number of nodes related to n are returned.
The Neo4j property graph database model consists of: Nodes describe entities (discrete objects) of a domain. Nodes can have zero or more labels to define (classify) what kind of nodes they are. Relationships describes a connection between a source node and a target node.
What you want is a version of having? People living in more than one city?
MATCH (p:PERSON)-[:LIVES]->(c:CITY) WITH p,count(c) as rels, collect(c) as cities WHERE rels > 1 RETURN p,cities, rels
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