Skip to content

Instantly share code, notes, and snippets.

@bifacil
Created August 11, 2019 12:49
Show Gist options
  • Save bifacil/d5683cdfe6502d2908827c27551786ab to your computer and use it in GitHub Desktop.
Save bifacil/d5683cdfe6502d2908827c27551786ab to your computer and use it in GitHub Desktop.
-- Ejemplo 4
COMBINE BY EnglishProductName
sales1 AS (
SELECT
DimProduct.EnglishProductName AS EnglishProductName,
sum(sales.OrderQuantity) AS Quantity2007
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
DimDate.CalendarYear=2007
AND DimProductCategory.SpanishProductCategoryName='Bicicleta'
AND DimDate.SpanishMonthName='Enero'),
sales2 AS (
SELECT
DimProduct.EnglishProductName AS EnglishProductName,
sum(sales.OrderQuantity) AS Quantity2008
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
DimDate.CalendarYear=2008
AND DimProductCategory.SpanishProductCategoryName='Bicicleta'
AND DimDate.SpanishMonthName='Enero')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment