Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.06 KB | None | 0 0
  1.  
  2.  
  3. --poblar tablas de modelo multidimensional (NorthWindDW) a partir de base de datos operacional (Northwind)*/
  4.  
  5. --dimension producto
  6. INSERT INTO DimProduct
  7.    SELECT p.productId, p.productName, c.categoryName
  8.    FROM Northwind.dbo.products p, Northwind.dbo.categories c
  9.    WHERE p.categoryID=c.categoryID;
  10.  
  11.  
  12. INSERT INTO DIMemployee
  13.    SELECT e.EmployeeID, e.FirstName + ' ' + e.LastName AS Name, e.City, e.Country, e.Region,e.HireDate
  14.    FROM Northwind.dbo.Employees e;
  15.    
  16.    
  17. --ejemplo de limpieza de datos, en Region y Country hay anomalias como valores nulos
  18. UPDATE DIMemployee SET Region='Europe' WHERE Country = 'UK';
  19.  
  20. --falta poblar customer.
  21. --DimTime ya la poblamos
  22.  
  23.  
  24. --  tablas de hechos
  25. INSERT INTO FactSales
  26. SELECT od.ProductID, o.EmployeeID, o.CustomerID, o.OrderDate ,
  27. o.orderID, od.quantity, od.unitPrice,
  28. od.discount,
  29. od.unitPrice * od.quantity * od.discount ,
  30. od.unitPrice * od.quantity - od.unitPrice * od.quantity * od.discount  
  31. FROM Northwind.dbo.Orders o, Northwind.dbo.[ORDER Details] od
  32. WHERE o.OrderID = od.OrderID;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement