Switzerland Movies

Using UNWIND pass on intermediate results

Add a WHERE clause to this query to filter the movies produced in Switzerland.

cypher
MATCH (m:Movie)
UNWIND m.countries AS country
WITH m, trim(country) AS trimmedCountry
// Add a WHERE clause to filter the results to 'Switzerland'
WITH trimmedCountry, collect(m.title) AS movies
RETURN trimmedCountry, size(movies)

Then answer this question:

Movies produced in Switzerland?

How many movies produced in Switzerland are in the graph?

  • ✓ 50

Hint

You can filter on the trimmedCountry variable that contains the country names after trimming the whitespace.

Solution

The answer is 50.

Run the following query to see the result:

cypher
MATCH (m:Movie)
UNWIND m.countries AS country
WITH m, trim(country) AS trimmedCountry
WHERE trimmedCountry = 'Switzerland'
WITH trimmedCountry, collect(m.title) AS movies
RETURN trimmedCountry, size(movies)

Summary

In this challenge, you answered another question about the graph.

In the next module, you will learn about subqueries in Cypher.