如果我想找到用户数超过平均用户数的组我添加了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数量的组用户,然后返回包含更多用户的组?
感谢。
答案 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