How Many Actors?
Update the query you just wrote to return the number of actors in movies with the same title.
cypher
MATCH (a:Actor)-[:ACTED_IN]->(m:Movie)
RETURN
m.title AS movie,
collect(a.name) AS actors
ORDER BY size(actors) DESC
LIMIT 100
How many actors are in the movies with the title Hamlet
?
-
✓ 24
Hint
You can use the size()
function to get the size of a list.
Solution
The answer is 24
.
Run the following query to see the result:
cypher
MATCH (a:Actor)-[:ACTED_IN]->(m:Movie)
RETURN
m.title AS movie,
collect(a.name) AS actors,
size(collect(a.name)) AS num
ORDER BY size(actors) DESC
LIMIT 100
Summary
In this challenge, you used size
to return the number of actors.
In the next lesson, you will learn about working with dates and times.