Ordering Multiple Values

Youngest actor

Youngest actor in highest rated movie

This query finds the highest rates movies:

cypher
MATCH (m:Movie)
WHERE m.imdbRating IS NOT NULL
RETURN m.title, m.imdbRating
ORDER BY m.imdbRating DESC

Your challenge is to find the youngest actor in the highest rated movie.

Modify this query to:

  1. Match Movie to Person nodes using the ACTED_IN relationship

  2. Add the Person node’s name and born property to the RETURN clause

  3. Order the results by the Person node’s born property

Who is the youngest actor that acted in the most highly-rated movie?

Enter the name (case-sensitive!):

  • ✓ Scott Grimes

Hint

Use the MATCH pattern (m:Movie)←[ACTED_IN]-(p:Person)`.

Add the Person node’s born property to the ORDER BY clause.

Solution

The correct answer is: "Scott Grimes".

You can run the following query to see the result:

cypher
MATCH (m:Movie)<-[ACTED_IN]-(p:Person)
WHERE m.imdbRating IS NOT NULL
RETURN m.title, m.imdbRating, p.name, p.born
ORDER BY m.imdbRating DESC, p.born DESC

Summary

In this challenge, you wrote a query to return results sorted by multiple values.

In the next lesson, you will learn limiting how much data is returned.