2017-05-17 45 views
1

我是neo4j中的新成員,我不知道如何在cypher中使用'gruop by'函數。如何在neo4j中使用按功能分組?

我有這樣的事情:

match(c:SEASON)<-[t:during]-(a:PLAYER)-[r:won]->(b:AWARD) 
return r.year as year, t.team as team 

返回我:

year team 

2011  OCK 
2011  OCK 
2011  LAS 
2010  LAS 
2010  SEA 
2010  OCK 

我會有這樣的:

year team  frequencies 

2011  OCK  2 
2011  LAS  1 
2010  LAS  1 
2010  SEA  1 
2010  OCK  1 

我知道我可以在SQL這樣做,但不是在密碼。 我感興趣的是其在同一年出現頻率最高的球隊,在2011年

由於這種情況下OCK提前

回答

4

Cypher支架沒有明確的組通過,相反,分組鍵由範圍內的非聚合列組成。以下是生成聚合列的Cypher aggregation functions

下面是使用的例子,使用COUNT()爲聚合列,這使得今年以來和團隊區域分組鍵含蓄:

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 
+0

感謝您的幫助! – manfr27