You are on page 1of 3

Clase semana 4 base de datos

Select * from Customers

Where city=’Berlin’ or city=’London’ or city ‘Buenos Aires’;

Select * from Customers

Where city in (‘Berlin’,’London’,’Buenos Aires’);

Uso de is null

Select * from Customers

Where region is null and fax is null;

Select * from Customers

Where region is null or fax is null;

Select * from Customers

Where region is not null and fax is not null;

select *
from Employees
where City in ('Seattle','Redmond','Tacoma') and City is not null and
Salary>2000;

uso del like


mostrar los registros cuyos nombres de la compañia inicien con las letras a y c
select *
from Customers
where CompanyName like 'a%' or CompanyName like 'c%';

select *
from Customers
where CompanyName like 'a%' or CompanyName like 'c%'
order by CompanyName
mostrar los datos de los contatos que terminen con la letra n
select *
from Customers
where CompanyName like '%n'

mostrar los datros de los contactos y direcciones encontrar que los nombres de los contacots sean
alizabet y las direcciones que inicien con un numero
select *
from Customers
where Address like '[0-9]%' or ContactName like 'eli%'

mostrar datos de los contactos cuyo tercer carácter sea o

select *
from Customers
where ContactName like '__o%'

uso de inner join y tablas produts, orderdetails, categories

select *
from Categories C
inner join Products P on c.CategoryID=p.CategoryID
inner join OrderDetails O on o.ProductID=p.ProductID;

ejercicios
1. calcular el importe de ventas (precio unitario * cantidad) para todos los números de orden entre
10250 y 10260 ademas que dicho importe sea mayor a 100

select(p.UnitPrice*o.Quantity) as 'importe de ventas'


from Categories c
inner join Products p on c.categoryId = p.CategoryID
inner join OrderDetails O on o.ProductID = p.ProductID
where OrderID >10250 and OrderID<10260 and (p.UnitPrice*o.Quantity)>100

select(p.UnitPrice*o.Quantity) as 'importe de ventas'


from Categories c
inner join Products p on c.categoryId = p.CategoryID
inner join OrderDetails O on o.ProductID = p.ProductID
where OrderID between 10250 and 10260
and (p.UnitPrice*o.Quantity)>100

mostrar todos los procustos de las categorias Condiments y Confecciones además cy¡uras cantidad
de ventas correspondana las ordenes <10260

select p.*
from Products p inner join OrderDetails d on p.ProductID=p.ProductID
inner join Categories c on p.CategoryID=c.CategoryID
where c.CategoryName in ('Confections','Condiments') and d.OrderID < 10260
select p.*
from Products p inner join OrderDetails d on p.ProductID=d.ProductID
inner join Categories c on p.CategoryID=c.CategoryID
where c.CategoryName in ('Confections','Condiments') and d.OrderID < 10260

You might also like