Skip to content

Instantly share code, notes, and snippets.

@bifacil
Created August 11, 2019 12:50
Show Gist options
  • Select an option

  • Save bifacil/4c566571a721543f8e8b9186f95abd38 to your computer and use it in GitHub Desktop.

Select an option

Save bifacil/4c566571a721543f8e8b9186f95abd38 to your computer and use it in GitHub Desktop.
--Ejemplo 5
COMBINE BY CalendarYear
isales1 AS (
SELECT
DimDate.CalendarYear AS CalendarYear,
sum(isales.SalesAmount) AS ventasInternet
FROM FactInternetSales isales
INNER JOIN DimDate ON (isales.OrderDateKey=DimDate.DateKey)
INNER JOIN DimCustomer ON (isales.CustomerKey=DimCustomer.CustomerKey)
INNER JOIN DimGeography ON (DimCustomer.GeographyKey=DimGeography.GeographyKey)
WHERE DimGeography.SpanishCountryRegionName='Francia'
GROUP BY DimDate.CalendarYear),
sales1 AS (
SELECT
DimDate.CalendarYear AS CalendarYear,
sum(sales.SalesAmount) AS ventasReseller
FROM FactResellerSales sales
INNER JOIN DimReseller ON (sales.ResellerKey=DimReseller.ResellerKey)
INNER JOIN DimGeography ON (DimReseller.GeographyKey=DimGeography.GeographyKey)
INNER JOIN DimDate ON (sales.OrderDateKey=DimDate.DateKey)
WHERE DimGeography.SpanishCountryRegionName='Francia'
GROUP BY DimDate.CalendarYear)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment