Retr0spect
Retr0spect

Reputation: 187

Neo4j: Actors who have acted in 40+ movies?

I have just started learning neo4j.

I am kind of stuck with creating this query.

Query: How many actors have acted in 10 or more movies?

Picture below shows the schema:

Schema

Upvotes: 1

Views: 610

Answers (2)

Michael Hunger
Michael Hunger

Reputation: 41686

If you have larger relationship-counts you might use the node degree directly, which is more efficient.

MATCH (a:Actor)
WHERE size( (a)-[:ACTS_IN]->() ) > 40
RETURN a

Upvotes: 3

Brian Underwood
Brian Underwood

Reputation: 10856

MATCH (a:Actor)-[:ACTS_IN]->(m:Movie)
WITH a, count(m) AS movie_count
WEHRE movie_count > 40
RETURN a

Upvotes: 3

Related Questions