Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
605 B
6
Indexable
Never
SELECT c.name AS name_category,
      COUNT(a.actor_id) AS total_films
FROM actor AS a
LEFT JOIN film_actor AS fa ON fa.actor_id = a.actor_id
LEFT OUTER JOIN film_category AS fc ON fc.film_id = fa.film_id
LEFT JOIN category AS c ON c.category_id = fc.category_id
WHERE a.actor_id IN(
    SELECT a.actor_id
    FROM movie AS m
    LEFT JOIN film_actor AS fa ON fa.film_id=m.film_id
    LEFT JOIN actor AS a ON fa.actor_id=a.actor_id
    WHERE m.release_year > '2013'
    GROUP BY a.actor_id
    HAVING COUNT(a.actor_id) > 7
)
GROUP BY name_category
ORDER BY total_films DESC, name_category;