Untitled

mail@pastecode.io avatar
unknown
sql
a year ago
676 B
3
Indexable
Never

SELECT c.name as name_category, COUNT(m.film_id) as total_films
FROM movie as m
JOIN film_category as fc ON m.film_id=fc.film_id
JOIN category as c ON fc.category_id=c.category_id
JOIN film_actor as fa ON m.film_id=fa.film_id
JOIN actor as a ON fa.actor_id=a.actor_id
WHERE a.actor_id IN (SELECT a.actor_id
                     FROM movie as m
                     JOIN film_actor as fa ON m.film_id=fa.film_id
                     JOIN actor as a ON fa.actor_id=a.actor_id
                     WHERE release_year > 2013
                     GROUP BY a.actor_id
                     HAVING COUNT(m.film_id) > 7)
GROUP BY name_category
ORDER BY total_films DESC, name_category