Using UNWIND pass on intermediate results
This query uses UNWIND
to find the number of movies containing each language.
cypher
MATCH (m:Movie)
UNWIND m.languages AS lang
WITH m, trim(lang) AS language
WITH language, collect(m.title) AS movies
RETURN language, size(movies)
Modify this query to return the number of movies produced in each country.
The country
property on Movie
nodes is a list of countries where the movie was produced.
Then answer this question:
UK movies?
How many movies released in the UK are in the graph?
-
✓ 1386
Hint
You should unwind by country
, rather than language
.
After you have collected the movies for each country as a list, return the size of the list for each country.
Solution
The answer is 1386
.
Run the following query to see the result:
cypher
MATCH (m:Movie)
UNWIND m.countries AS country
WITH m, trim(country) AS trimmedCountry
WITH trimmedCountry, collect(m.title) AS movies
RETURN trimmedCountry, size(movies)
Summary
In this challenge, you modified a query that uses UNWIND
.
In the next challenge, you will answer another question from the query.