问题
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?
回答1:
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
来源:https://stackoverflow.com/questions/18138752/can-neo4j-cypher-query-do-similar-thing-as-having-in-sql