Highest Average Rating

Using WITH pass on intermediate results

Using the query you just wrote:

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

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?

Solution

The answer is 4.2.

Run the following query to see the result:

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

Summary

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

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