Advertisement
deniswhite77

Untitled

Feb 21st, 2022
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SELECT c.name AS name_category,
  2.        COUNT(DISTINCT m.film_id) AS total_films
  3. FROM movie AS m LEFT JOIN film_actor AS fa ON fa.film_id=m.film_id
  4. LEFT JOIN actor AS a ON a.actor_id=fa.actor_id
  5. LEFT JOIN film_category AS fc ON m.film_id=fc.film_id
  6. LEFT JOIN category AS c ON c.category_id=fc.category_id
  7. WHERE a.actor_id IN (SELECT a.actor_id
  8.                      FROM movie AS m LEFT JOIN film_actor AS fa ON fa.film_id=m.film_id
  9.                      LEFT JOIN actor AS a ON a.actor_id=fa.actor_id
  10.                      WHERE m.release_year > 2013
  11.                      GROUP BY a.actor_id
  12.                      HAVING COUNT(a.actor_id)>7)
  13. GROUP BY name
  14. ORDER BY total_films DESC, name_category;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement