我正在尝试将我提交表中的所有数据插入到我的事实表中。除状态列外,所有字段都排成一行。状态表需要根据日期填写状态。我有我需要的规则,但我不确定我应该把这个逻辑放在哪里,甚至不知道如何去做。任何帮助表示赞赏。
Insert into dbo.FactSubmit
(
ProjectKey,
DueFromSubKey,
SentToKey,
DueFromArcKey,
ReceivedDateKey,
[Description],
Status
)
Select
dp.ProjectKey,
CONVERT(int, Convert(varchar, s.Due_From_Sub ,112)),
CONVERT(int, Convert(varchar,s.Sent_To, 112)),
CONVERT(int, Convert(varchar,s.Due_From_Arc, 112)),
CONVERT(int, Convert(varchar,s.ReceivedDate, 112)),
s.Item_Description
From stg.Submit s
INNER JOIN dbo.DimProject dp
ON s.ProjectID = dp.ProjectID
INNER JOIN stg.Project sp
ON sp.ProjectID = dp.ProjectID