neo4j中的密码查询中如何有两个聚合? [英] how to have two aggregation in cypher query in neo4j?
本文介绍了neo4j中的密码查询中如何有两个聚合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对复杂的查询有疑问; 这是我的密码查询:
i have problem with complex queries; here is my cypher query:
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是每个组的用户.
我如何统计群组用户的平均值并将其与每个群组用户的数量进行比较?
如何获取群组用户的平均人数,然后返回用户人数超过平均人数的群组?
谢谢.
n
is the group name and x is the users of each group.
how can i have avg of group users count and compare it with each group users count?
can I get the average number of group users and then return the groups with more users than avg?
Thanks.
推荐答案
我认为您不重新启动就无法在同一查询中获得平均值和计数.所以这是我的尝试:
I don't think you can get the avg and the counts in the same query, without restarting. So here's my attempt:
start n=node:groups({query})
match n<-[:Members_In]-x
with n, count(distinct x) as cnt
with avg(cnt) as av
start n=node:groups({query})
match n<-[:Members_In]-x
with n, av, count(distinct x) as numOfUsers
where numOfUsers > av
return n.name, numOfUsers, av
这篇关于neo4j中的密码查询中如何有两个聚合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文