UK Movies

Using UNWIND pass on intermediate results

You have already seen this query:

cypher
MATCH (m:Movie)
UNWIND m.languages AS lang
WITH m, trim(lang) AS language
// this automatically, makes the language distinct because it's a grouping key
WITH language, collect(m.title) AS movies
RETURN language, movies[0..10]

Modify this query to return the number of movies released in each country.

Then answer this question:

UK movies?

How many movies released in the UK are in the graph?

  • ✓ 1386

Hint

You will unwind by countries, rather than languages.

After you have collected the movies for each language as a list, return the size of the list for each country.

How many movies released in the UK are in the graph?

Once you have entered the answer, click the Try Again button below to continue.

Solution

You can run the following query to find the answer:

cypher
MATCH (m:Movie)
UNWIND m.countries AS country
WITH m, trim(country) AS trimmedCountry
// this automatically, makes the trimmedCountry distinct because it's a grouping key
WITH trimmedCountry, collect(m.title) AS movies
RETURN trimmedCountry, size(movies)

How many movies released in the UK are in the graph?

Once you have entered the answer, click the Try Again button below to continue.

Summary

In this challenge, you modified a query that uses UNWIND.

In the next challenge, you will answer another question from the query.

Chatbot

Hi, I am an Educational Learning Assistant for Intelligent Network Exploration. You can call me E.L.A.I.N.E.

How can I help you today?