Created
August 11, 2019 12:48
-
-
Save bifacil/f447dcad1ef12ed138cb60fcda004d1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
DimProduct.EnglishProductName AS Producto, | |
sum(sales.OrderQuantity) AS Unidades, | |
sum(sales.SalesAmount) AS Importe, | |
sum(sales.SalesAmount)/sum(sales.OrderQuantity) AS [Precio Medio] | |
FROM FactResellerSales sales | |
INNER JOIN DimProduct ON (sales.ProductKey=DimProduct.ProductKey) | |
INNER JOIN DimProductSubCategory ON (DimProduct.ProductSubcategoryKey=DimProductSubCategory.ProductSubcategoryKey) | |
INNER JOIN DimProductCategory ON (DimProductSubCategory.ProductCategoryKey=DimProductCategory.ProductCategoryKey) | |
INNER JOIN DimDate ON (sales.OrderDateKey=DimDate.DateKey) | |
WHERE | |
DimProductCategory.SpanishProductCategoryName='Bicicleta' | |
AND DimDate.SpanishMonthName='Enero' | |
AND DimDate.CalendarYear=2008 | |
GROUP BY DimProduct.EnglishProductName | |
ORDER BY (sum(sales.SalesAmount)/sum(sales.OrderQuantity)) DESC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment