Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://practicum.yandex.ru/trainer/sql-data-analyst/lesson/1739fbcf-17cf-48d0-bb4c-0a448cec10ab/task/ec31dab3-54af-44ad-8f89-498fe10c448f/
- SELECT ct.name,
- AVG(m.length)
- FROM movie AS m
- LEFT OUTER JOIN film_category AS fc ON m.film_id = fc.film_id
- LEFT OUTER JOIN category AS ct ON fc.category_id = ct.category_id
- WHERE m.film_id IN (
- SELECT mv.film_id
- FROM movie AS mv
- GROUP BY mv.film_id
- ORDER BY SUM(mv.rental_rate) DESC
- LIMIT 50)
- GROUP BY ct.name
- ORDER BY AVG(m.length) DESC;
Advertisement
Add Comment
Please, Sign In to add comment