Académique Documents
Professionnel Documents
Culture Documents
1. CODIGOS BASICOS
use Northwind
SELECT * FROM Customers (CLIENTES)
use Northwind
SELECT * FROM Employees (EMPLEADOS)
use Northwind
SELECT * FROM Suppliers (PROVEEDORES)
NO HAY RELACION
use Northwind
SELECT CompanyName AS NAME, COUNTRY AS CIUDAD FROM Suppliers
15. MOSTRAR LOS CLIENTES CUYO NOMBRE EMPIEZA POR LA LETRA ¨W¨
use Northwind
SELECT * FROM Customers WHERE CompanyName LIKE 'W%'
use Northwind
SELECT * FROM Customers WHERE Address LIKE '%KI%'
19. MOSTRAR LAS VENTAS DEL PRODUCTO 65 CON CANTIDADES ENTRE 5 Y 10, O QUE NO
TENGAN DESCUENTO
use Northwind
SELECT * FROM [Order Details] WHERE (ProductID = 65 AND Quantity BETWEEN 5 AND
10) OR Discount =0
23. LISTAR TODOS LOS PROVEEDORES CON EL NOMBRE DEL PRODUCT QUE NOS VENDEN
use Northwind
select DISTINCT Suppliers.CompanyName, Products.SupplierID, products.ProductName
from Suppliers inner join
products on suppliers.SupplierID = products.SupplierID
25. Listar todos los proveedores que, sus unidades de product (unitsonorder),
esta entre 10 y 50
29. SUMAR TODOS LOS VALORES DE LOS PRODUCTOS (UNITPRICE) CON VALOR ARRIBA DE
2500
use Northwind
select ProductID, SUM (UnitPrice) FROM [Order Details] GROUP BY ProductID HAVING
SUM (UnitPrice) > 2500
31. LISTAR TODOS LOS NOMBRES DE LOS PROVEEDORES ADEMAS DE SU PAIS, Y EL NOMBRE
DEL PRODUCTO
USE Northwind
Select suppliers.companyname, suppliers.Contactname, dbo.suppliers.country,
Products.ProductName, Products.UnitPrice from suppliers inner join Products on
Suppliers.SupplierID = Products.SupplierID
32. LISTAR TODOS LOS NOMBRES DE LOS PROVEEDORES ADEMAS DE SU PAIS, Y EL NOMBRE
DE LA CATEGORIA
33. LISTAR LOS CLIENTES CON SU DIRECCION, ID DE ORDEN, FECHA DE ENTREGA Y EL
NOMBRE DE LA COMPAÑIA QUE REALIZARA LA ENTREGA
--Mostrar los clientes a los que se les realizaron ordenes durante el año de 1997
Select Customers.CompanyName, Orders.OrderDate, Orders.CustomerID from Customers
inner join Orders
on Customers.CustomerID=Orders.CustomerID where Orders.OrderDate between '1997-
01-01' and '1997-31-12'
--Consultas
use Northwind
SELECT * FROM Customers Where Region IN('CA','MT', 'WA') ORDER BY Region,
CompanyName Desc
--Consultas
use Northwind
SELECT * FROM Employees where EmployeeID BETWEEN 3 AND 15