This article describes how to use the `WITH` keyword in cypher queries.
Assume you want to get the Movies where the average length of its Actor names is 12.
If you try writing the below query, the cypher would throw an error.
MATCH (m:Movie)<-[:ACTED_IN]-(a:Actor) WHERE avg(size(a.name)) = 12 RETURN m
Invalid use of aggregating function avg(...) in this context (line 2, column 7 (offset: 45)) "WHERE avg(size(a.name)) = 12"
This can be addressed by using the WITH keyword in your cypher syntax as below:
MATCH (m:Movie)<-[:ACTED_IN]-(a:Actor) WITH m, avg(size(a.name)) AS averageSize WHERE averageSize = 12 RETURN m