man*_*r27 6 group-by neo4j cypher
我是neo4j的新手,我不知道如何在cypher中使用'gruop by'功能.
我有这样的事情:
match(c:SEASON)<-[t:during]-(a:PLAYER)-[r:won]->(b:AWARD)
return r.year as year, t.team as team
Run Code Online (Sandbox Code Playgroud)
那让我回报:
year team
2011 OCK
2011 OCK
2011 LAS
2010 LAS
2010 SEA
2010 OCK
Run Code Online (Sandbox Code Playgroud)
我会这样的:
year team frequencies
2011 OCK 2
2011 LAS 1
2010 LAS 1
2010 SEA 1
2010 OCK 1
Run Code Online (Sandbox Code Playgroud)
我知道如何在SQL中完成它而不是在cypher中.我对同年频率最高的团队感兴趣,在本案例中是2011年的OCK.
提前致谢
Cypher没有明确的分组,而是分组密钥由范围中的非聚合列组成.以下是生成聚合列的Cypher聚合函数.
这是一个使用示例,使用COUNT()作为聚合列,使year和team字段隐式地成为分组键:
match(c:SEASON)<-[t:during]-(a:PLAYER)-[r:won]->(b:AWARD)
return r.year as year, t.team as team, count(t.team) as frequency
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9151 次 |
| 最近记录: |