SQL has "Having" clause, for example:
SELECT LastName, COUNT(*)
FROM Employees
GROUP BY LastName
HAVING COUNT(*) > 10;
In Cypher, we can do count()
START n=node(2)
MATCH (n)-[r]->()
RETURN type(r), count(*)
But does Cypher have similar function as "Having", or is there any workaround?
Sure, having is just one of the many uses of query chaining with WITH
which is similar to RETURN
but determines which elements will be available in the next query part. WITH
also supports ordering and paging.
START n=node(2)
MATCH (n)-[r]->()
WITH type(r) as t, count(*) as c
WHERE c > 10
RETURN t,c
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