0

我有复杂查询的问题;这是我的密码查询:

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 是每个组的用户。我如何获得组用户数的平均值并将其与每个组用户数进行比较?我可以获取组用户的平均数量,然后返回用户数超过平均数的组吗?谢谢。

4

1 回答 1

2

我认为您无法在不重新启动的情况下在同一个查询中获得平均值和计数。所以这是我的尝试:

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
于 2012-12-09T05:46:28.027 回答