Aggregation in cypher
Aggregation in Cypher (for BangDB) just works. Users select aggregate columns along with non-aggregated columns. The non-aggregated columns become groupby keys.
To find out how often an actor and director worked together, run the following:
S=>(@p Person:*)-[@d DIRECTED]->(@m Movie:*)<-[@a ACTED_IN]-(@p2 Person:*); RETURN p2.name AS actor, p.name AS director, COUNT(*) AS collabs
+-------+-----------+---------+
| actor | director | collabs |
+-------+-----------+---------+
| tom | robert | 1 |
+-------+-----------+---------+
To find how many times actors have had appearances
S=>(@p Person:*)-[@a ACTED_IN]->(@m Movie:*); RETURN p.fullname AS actor, COUNT(*) AS appearances
+---------------+------------------+
| actor | appearances |
+---------------+------------------+
| Tom Hanks | 2 |
+---------------+------------------+