Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Respuestas
-----------Ejercicio 1------------
declare @mes int
select [Venta Total]=sum(od.Quantity)
,c.CategoryName
from Orders t0
inner join [Order Details] od on t0.OrderID =od.OrderID
inner join Products p on p.ProductID=od.ProductID
inner join Categories c on c.CategoryID=p.CategoryID
group by c.CategoryName
order by [Venta Total] desc
-----------Ejercicio 2------------
set @mes=12
select Mes=month(OrderDate)
,[Venta Total]=sum(od.Quantity)
,c.CategoryName
from Orders t0
inner join [Order Details] od on t0.OrderID =od.OrderID
inner join Products p on p.ProductID=od.ProductID
inner join Categories c on c.CategoryID=p.CategoryID
where month(OrderDate)=@mes
group by c.CategoryName ,month(OrderDate)
order by [Venta Total] desc
-----------Ejercicio 3------------
set @mes=12
select Mes=month(OrderDate)
,[Venta Total]=sum(od.Quantity)
,c.CategoryName
from Orders t0
inner join [Order Details] od on t0.OrderID =od.OrderID
inner join Products p on p.ProductID=od.ProductID
inner join Categories c on c.CategoryID=p.CategoryID
where month(OrderDate)=@mes
group by c.CategoryName ,month(OrderDate)
order by [Venta Total] asc
-----------Ejercicio 4------------
set @mes=5
select Mes=month(OrderDate)
,[Venta Total]=sum(od.Quantity)
,c.CategoryName,p.UnitPrice
from Orders t0
inner join [Order Details] od on t0.OrderID =od.OrderID
inner join Products p on p.ProductID=od.ProductID
inner join Products on p.UnitPrice=od.UnitPrice
inner join Categories c on c.CategoryID=p.CategoryID
where month(OrderDate)=@mes
group by c.CategoryName ,month(OrderDate), p.UnitPrice
order by UnitPrice desc
-----------Ejercicio 5------------
-----------Ejercicio 7------------
SELECT e.LastName,e.FirstName,Total= sum(od.Quantity)
FROM employees e
inner join orders o on e.EmployeeID=o.EmployeeID
inner join [Order Details] od on o.OrderID=od.OrderID
group by e.EmployeeID, e.FirstName, e.LastName
order by Total desc
-----------Ejercicio 8------------
Select p.ProductName, p.SupplierID
From Products p
inner join Suppliers s on p.SupplierID=p.SupplierID
group by p.ProductName, p.SupplierID
-----------Ejercicio 9------------
Select LastName,FirstName, BirthDate
from Employees
order by MONTH(BirthDate)
-----------Ejercicio 10-----------