This is what I'm trying:
match
(e:Person) - [r] - (f:Person)
where (count(r) > 5 AND count (r) <10)
return id(e), e.name;
I get
QueryExecutionKernelException: Invalid use of aggregating function count(...) in this context
Basically I'm wanting to find a Person who is related to between 5 and 10 other Persons.
We can use CASE to evaluate a boolean condition and output a single-element list, or an empty list, and this drives the conditional Cypher execution (to execute the subsequent write-only clauses, or not).
If the list is empty, then the contained Cypher will not execute. We can use CASE to evaluate a boolean condition and output a single-element list, or an empty list, and this drives the conditional Cypher execution (to execute the subsequent write-only clauses, or not).
If a list has 1 element, then the Cypher in the FOREACH will execute. If the list is empty, then the contained Cypher will not execute. We can use CASE to evaluate a boolean condition and output a single-element list, or an empty list, and this drives the conditional Cypher execution (to execute the subsequent write-only clauses, or not).
COUNT, MAX, etc.) in A WHERE clause. Hence we use the HAVING clause instead. Therefore the whole query would be similar to this: SELECT column_name, aggregate_function(column_name) FROM table_name WHERE column_name operator value GROUP BY column_name HAVING aggregate_function(column_name) operator value;
to find out people who are connected with each other by more than relationship ex:
use
match (a:Person)-[r]-(b:person)
with a,b,count(r) as cnt
where cnt > 5 and cnt < 10
return *
if however you want to find people who are connected as a chain ( friends of friends )
and you want to find a to d then you can use something like
MATCH (n:Person)-[r*1..3]->(m:Person)
RETURN *
relevant tutorial heer
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