In Neo4j, there is no "GROUP BY" clause like relational database queries. However, you can use aggregation functions along with WITH clauses to achieve the same effect. The WITH clause groups by key and allows you to apply aggregation functions like count(), sum(), avg(), collect(), etc.
Here are some example Cypher queries:
Count value for books_written grouped by author
MATCH (a:Author)-[:WROTE]->(b:Book)
WITH a.name AS author, count(b) AS books_written
RETURN author, books_written
Average value for price grouped by category
MATCH (p:Product)
WITH p.category AS category, avg(p.price) AS average_price
RETURN category, average_price