方法1 在源表上操作
事实表
use northwind
select A.ProductID,B.CustomerID,B.EmployeeID,B.OrderDate,A.UnitPrice*A.Quantity as JinEr from [Order details]as A , Orders as B
where A.OrderID = B.OrderID
时间
use northwind
select DISTINCT
OrderDate as timeId ,DATEPART(m, OrderDate) as months, DATEPART(d, OrderDate) as days, DATEPART(yy, OrderDate) as years,DATEPART(q, OrderDate) as quarter
from Orders
产品
use northwind
SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice]
FROM [Northwind].[dbo].[Products]
方法2 在目标表上操作
事实表
use mydbase
--drop table sales_fact
select A.ProductID,B.CustomerID,B.EmployeeID,B.OrderDate as timeId ,A.UnitPrice*A.Quantity as JinEr
into sales_fact
from northwind.dbo.[Order details]as A , northwind.dbo.Orders as B
where A.OrderID = B.OrderID
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载