Can Neo4j Cypher query do similar thing as “Having” in SQL?

ぐ巨炮叔叔 提交于 2021-01-28 04:43:44

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!