Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --poblar tablas de modelo multidimensional (NorthWindDW) a partir de base de datos operacional (Northwind)*/
- --dimension producto
- INSERT INTO DimProduct
- SELECT p.productId, p.productName, c.categoryName
- FROM Northwind.dbo.products p, Northwind.dbo.categories c
- WHERE p.categoryID=c.categoryID;
- INSERT INTO DIMemployee
- SELECT e.EmployeeID, e.FirstName + ' ' + e.LastName AS Name, e.City, e.Country, e.Region,e.HireDate
- FROM Northwind.dbo.Employees e;
- --ejemplo de limpieza de datos, en Region y Country hay anomalias como valores nulos
- UPDATE DIMemployee SET Region='Europe' WHERE Country = 'UK';
- --falta poblar customer.
- --DimTime ya la poblamos
- -- tablas de hechos
- INSERT INTO FactSales
- SELECT od.ProductID, o.EmployeeID, o.CustomerID, o.OrderDate ,
- o.orderID, od.quantity, od.unitPrice,
- od.discount,
- od.unitPrice * od.quantity * od.discount ,
- od.unitPrice * od.quantity - od.unitPrice * od.quantity * od.discount
- FROM Northwind.dbo.Orders o, Northwind.dbo.[ORDER Details] od
- WHERE o.OrderID = od.OrderID;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement