Using Subqueries

Add a subquery

Top French movie

Here is your starter code:

cypher
MATCH (g:Genre)
// write subquery
RETURN g.name AS genre, numMovies
ORDER BY numMovies DESC

Write and execute the subquery to return the movie nodes that have a countries list element of 'France'.

  1. You must pass in the g variable to the subquery.

  2. You must test if the movie node for that genre was released in France.

  3. The subquery must return the count of the movie nodes, numMovies for each Genre passed in.

How many movies were in the largest Genre category for movies released in France? (enter a number)

  • ✓ 277

Hint

Use WITH to pass in the Genre reference.

The subquery will find all movies of that Genre released in France. It will return the count of the movies.

How many movies were in the largest Genre category for movies released in France? (enter a number)

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 (g:Genre)
CALL { WITH g
MATCH (g)<-[:IN_GENRE]-(m) WHERE 'France' IN m.countries
RETURN count(m) AS numMovies
}
RETURN g.name AS Genre, numMovies ORDER BY numMovies DESC

How many movies were in the largest Genre category for movies released in France? (enter a number)

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

Summary

In this challenge, you answered a question by writing a Cypher subquery.

In the next challenge you will write a query to combine results.

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?