andrey_vetrov

Untitled

Apr 5th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. https://practicum.yandex.ru/trainer/sql-data-analyst/lesson/1739fbcf-17cf-48d0-bb4c-0a448cec10ab/task/ec31dab3-54af-44ad-8f89-498fe10c448f/
  2.  
  3. SELECT ct.name,
  4. AVG(m.length)
  5. FROM movie AS m
  6. LEFT OUTER JOIN film_category AS fc ON m.film_id = fc.film_id
  7. LEFT OUTER JOIN category AS ct ON fc.category_id = ct.category_id
  8. WHERE m.film_id IN (
  9. SELECT mv.film_id
  10. FROM movie AS mv
  11. GROUP BY mv.film_id
  12. ORDER BY SUM(mv.rental_rate) DESC
  13. LIMIT 50)
  14. GROUP BY ct.name
  15. ORDER BY AVG(m.length) DESC;
Advertisement
Add Comment
Please, Sign In to add comment