Highest Average Rating

Using WITH pass on intermediate results

Use the query that you just wrote to answer this question:

What is the highest average rating for a movie acted in by Tom Hanks?

Based upon the query you just executed, enter the highest average rating.

  • ✓ 4.2

Hint

The query you executed in the last challenge should answer this question:

cypher
MATCH (p:Person)-[:ACTED_IN]->(m:Movie)<-[r:RATED]-(:User)
WHERE p.name = 'Tom Hanks'
WITH m, avg(r.rating) AS avgRating
WHERE avgRating > 4
RETURN m.title AS Movie, avgRating AS `AverageRating`
ORDER BY avgRating DESC

What is the highest average rating?

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 (p:Person)-[:ACTED_IN]->(m:Movie)<-[r:RATED]-(:User)
WHERE p.name = 'Tom Hanks'
WITH m, avg(r.rating) AS avgRating
WHERE avgRating > 4
RETURN m.title AS Movie, avgRating AS `AverageRating`
ORDER BY avgRating DESC

What is the highest average rating?

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

Summary

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

In the next lesson, you will learn about unwinding lists during a query.