You are on page 1of 2

insert into categorias(categoriaId,categoriaNombre)

values (1,'electodomesticos');

--
select productname
from products
where productId=4 or productId=6;

--obtner un listado con un select


select productname
from products
where productId in (4,6);
--
select p.productname
from productos p
where p.productId =4
UNION
select q.productname
from products q
where q.productId=6

--no hacer orderbyantes Un


select contactname
from customers
Union
select companyname
from suppliers
orderby

--
select * from products p
where p.categoryId in(select categoryId
from categories
where categoryname like'c%');
---
Select a.
from(Select c.categoryId,max(unit price) maximo
From products p
inner join categories c on p.categoryId= c.categoryId
group by c.categoryId)
--
Si queremos saber la cantidad de libros agrupados por editorial pero considerando
s�lo algunos grupos,por ejemplo, los que devuelvan un valor mayor a 2,

select editorial, count(*) from libros


group by editorial
having count(*)>2
---
Mostrar la cantidad de proveedores que existen por ciudad

select ci.cityname,count()
from suppliers su
inner join cities ci on su.cityId = ci.cityid
group by ci.cityname
having count()>1;

/
Mostrar la cantidad de proveedores que existen por pais
---
select co.countryname,count()
from suppliers su
inner join cities ci on su.cityId = ci.cityid
inner join countries co on ci.countryid = co.countryid
group by co.countryname;
---
Cantidad de ordenes puesta por cada empleado /
select e.lastname, e.firstname, count()
from orders o
inner join employees e on o.employeeid = e.employeeid
group by e.lastname, e.firstname;

You might also like