Está en la página 1de 4

1.-Contar el total de tiendas por ciudad.

Select city , count (stor_id)


as Total_De_Tiendas_Por_Ciudad
from stores
group by city

2.- Contar el total de tiendas por estado.

Select state , count (stor_id)


as Total_De_Tiendas_Por_Estado
from stores
group by state

3.- Recuperar el número, nombre, dirección y ciudad de las tiendas cuyas ventas sean
mayor a 30 libros.

Select stor_id, stor_name,stor_address,city


from stores
where stor_id in(
Select stor_id
from sales
group by stor_id
having sum (qty)>30)
4.-Recuperar la información de los nombres y precios de los libros que han vendido en las
tiendas.

Select title, price from titles


where title_id in (select title_id
from sales group by title_id)

5.- Listar los números, nombres y precios de los libros cuyos autores viven en el estado
de California.

Select title_id,title, price


from titles
where title_id in (
Select title_id
from titleauthor
where au_id in (Select au_id from authors where (state='CA')))
6.- Recuperar los números, nombre, tipo y precio de los libros del tipo 'Business'.

Select title_id,title, type ,price


from titles
where (type='Business')

7.-Contar los autores por estado.

Select state ,count (au_id) as Total_De_Autores_Por_Estado


from authors
group by state
8.-Listar la información de los libros de cómputo (‘Popular_comp’), ordenados
ascendentemente.

Select * from titles where type ='popular_comp' order by title asc

9.- Contar los empleados por editorial.

Select pub_id, count (emp_id)


as Total_Empleados_Por_Editorial
from employee
group by pub_id

10.-Recuperar la información de los autores que han vendido más de 20 libros.


Select* from authors
where au_id in(select au_id from titleauthor where title_id
in (select title_id from sales group by title_id having sum(qty)>20))

También podría gustarte