知识库

如何用 Cypher 实现等同于 SQL HAVING 子句的功能

在传统的基于 SQL 的数据库中,HAVING 子句用于限制聚合值。例如

select zipcode, count(*) as population
from Person
group by zipcode
having population>100000;

将返回所有居民超过10万的邮政编码。要在 Cypher 中实现相同的功能,请使用以下语句

match (n:Person)
with n.zipcode as zip, count(*) as population
where population > 100000
return zip, population
© . This site is unofficial and not affiliated with Neo4j, Inc.