Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- c.NAME AS name_category,
- COUNT(fc.film_id) AS total_films
- FROM
- category AS c
- LEFT OUTER JOIN film_category AS fc ON fc.category_id = c.category_id
- LEFT OUTER JOIN movie AS m ON m.film_id = fc.film_id
- LEFT OUTER JOIN film_actor AS fa ON fa.film_id = m.film_id
- WHERE
- fa.actor_id IN (
- -- Актеры снимающиеся более 7 раз в фильмах после 2013 года
- SELECT
- film_actor.actor_id
- FROM
- movie
- INNER JOIN film_actor ON film_actor.film_id = movie.film_id
- WHERE
- movie.film_id IN (
- -- Фильмы снятые после 2013
- SELECT
- movie.film_id
- FROM
- movie
- WHERE
- release_year > 2013
- )
- GROUP BY
- film_actor.actor_id
- HAVING
- COUNT(movie.film_id) > 7
- )
- GROUP BY
- name_category
- ORDER BY
- total_films DESC,
- name_category
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement