Ejercicios Base de datos

Total de pagos por países

select country, sum(amount) total from
country join city using (country_id)
join address using (city_id)
join customer using (address_id)
join payment using (customer_id)
group by country

Películas con más de diez actores

select title, count(actor_id) actores
from film join film_actor using (film_id)
group by title
having actores>10

Actor que ha trabajado en más películas

select first_name, last_name, count(film_id) peliculas
from actor join film_actor using(actor_id)
group by first_name, last_name
order by peliculas desc
limit 0,1

Actores que han hecho películas de acción

select distinct first_name, last_name,name
from actor join film_actor using(actor_id)
join film using(film_id)
join film_category using(film_id)
join category using(category_id)
where name=’Action’
order by first_name,last_name

Países con más de 50 clientes

select country, count(customer_id) total from
country join city using (country_id)
join address using (city_id)
join customer using (address_id)
group by country
having total>50

Publicado por

Juan Pablo Fuentes

Formador de programación y bases de datos