Skip to content

Instantly share code, notes, and snippets.

@bifacil
Created August 11, 2019 12:47
Show Gist options
  • Save bifacil/40848fc9dbde5f0f9bcd4b98e5c05503 to your computer and use it in GitHub Desktop.
Save bifacil/40848fc9dbde5f0f9bcd4b98e5c05503 to your computer and use it in GitHub Desktop.
-- Ejemplo 1
SELECT
DimProduct.EnglishProductName AS Producto,
sum(sales.OrderQuantity) AS Unidades,
sum(sales.SalesAmount) AS Importe,
Importe/Unidades AS [Precio Medio]
FROM FactResellerSales sales
INNER JOIN DimProduct USING ProductKey
INNER JOIN DimProductSubCategory USING DimProduct(ProductSubcategoryKey)
INNER JOIN DimProductCategory USING DimProductSubCategory(ProductCategoryKey)
INNER JOIN DimDate USING (OrderDateKey DateKey)
WHERE
DimProductCategory.SpanishProductCategoryName='Bicicleta'
AND DimDate.SpanishMonthName='Enero'
AND DimDate.CalendarYear=2008
ORDER BY [Precio Medio] DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment