Está en la página 1de 2

clase 5

#1.- ¿Cuantas películas fueron rentadas en cada categoría?¿cuál fue el top 5?

#(Notar que no hay una consulta ‘correcta’ estas pueden ser distintas y llegar al mismo resultado)

Select

count(film_id) as Total_peliculas, categoria

from film f inner join film_category fc

on f.film_id = fc.film_id

inner join category cat

on fc.category_id = cat.category_id

group by category_id

order by 1 desc

select name , count(rental_id) from rental

inner join inventory

on rental.inventory_id = inventory.inventory_id

inner join film on

inventory.film_id = film.film_id

inner join film_category on

film.film_id = film_category.film_id

inner join category on

film_category.category_id = category.category_id

group by category.name

order by total desc

limit 5;

#2.- ¿Cuál es el numero de rentas procesadas por el staff por mes en cada negocio?

# (solo se pide la fecha, el negocio y el total)


Select

count(rental_id) as total_rentas, mes , negocio

from rental st inner join film_category fc

on f.film_id = fc.film_id

inner join category cat

on fc.category_id = cat.category_id

group by category_id

order by 1 desc

select staff.store_id , count(rental_id)from rental

inner join staff on

rental.staff_id = staff.staff_id

group by store_id

select staff.store_id , count(rental_id)from rental

inner join staff on

rental.staff_id = staff.staff_id

group by store_id

También podría gustarte