我可以获得所有组中的平均用户数,然后返回neo4j中cypher查询中包含更多用户的组吗?

时间:2012-12-05 20:02:32

标签: neo4j cypher

如果我想找到用户数超过平均用户数的组我添加了where子句,但我们不能在哪里使用聚合.... 这是我的密码查询:

params.put("query", "name:*");
ExecutionResult result = engine.execute( "start n=node:groups({query}) 
match n<-[:Members_In]-x 
with n,count(distinct x) as numberOfUsers
where numOfUsers>avg(numOfUsers) 
return  n.name,numOfUsers ", params );

n是组名,x是每个组的用户。 如何获得avg数量的组用户,然后返回包含更多用户的组? 感谢。

1 个答案:

答案 0 :(得分:0)

尝试使用WITH,例如

start n=node(*) 
match n<-[:Members_In]-x 
with n, count(distinct x) as countOfUsers
with n, avg(countOfUsers) as avg 
where avg<3 
return  n.name, avg

示例http://tinyurl.com/czkpmws