Skip to content

Instantly share code, notes, and snippets.

@bagvendt
Created October 24, 2013 20:35
Show Gist options
  • Save bagvendt/7144538 to your computer and use it in GitHub Desktop.
Save bagvendt/7144538 to your computer and use it in GitHub Desktop.
Find every actor that has appeared in at least 20 rated movies.
SELECT * FROM (
SELECT actor_id, COUNT(*) as count FROM actors
JOIN `roles`
ON actors.`id` = roles.`actor_id`
JOIN `movies`
ON movies.`id` = `movie_id`
WHERE rank IS NOT NULL
GROUP BY actor_id) a
WHERE a.count >= 20;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment