Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Group by
Lista número de productos por categoría.
select f.Name, count(d.ProductID) as [#Productos]
from Production.Product d
inner join Production.ProductSubcategory e on e.ProductSubcategoryID=d.ProductSubcategoryID
inner join Production.ProductCategory f on e.ProductCategoryID=f.ProductCategoryID
group by f.Name
NERM Pagina 1 de 3
UTEC C02/2019 BAS2-I01
NERM Pagina 2 de 3
UTEC C02/2019 BAS2-I01
Order by
Listado de lo total comprado en año y mes por categoría.
select e.Name as [Nombre Categoria],
year(a.OrderDate) as [Año],
month(a.OrderDate) as Mes,
sum(a.TotalDue) as Total
from Purchasing.PurchaseOrderHeader a
inner join Purchasing.PurchaseOrderDetail b on b.PurchaseOrderID=a.PurchaseOrderID
inner join Production.Product c on b.ProductID=c.ProductID
inner join Production.ProductSubcategory d on d.ProductSubcategoryID=c.ProductSubcategoryID
inner join Production.ProductCategory e on e.ProductCategoryID=d.ProductCategoryID
group by e.Name, year(a.OrderDate), month(a.OrderDate)
Análisis.
Realizando análisis de datos con Excel al utilizar la siguiente consulta:
select f.ProductCategoryID, f.Name, e.ProductSubcategoryID, e.Name, d.ProductID, d.Name
from Production.Product d
inner join Production.ProductSubcategory e on e.ProductSubcategoryID=d.ProductSubcategoryID
inner join Production.ProductCategory f on e.ProductCategoryID=f.ProductCategoryID
NERM Pagina 3 de 3