0

假设我有四个不同的脚本,并且所有的列都将用于创建一个 Fact 表,如果我将这四个脚本粘贴到 OLE DB 源中的 SQL 命令中,它会起作用吗?考虑到我创建了一个表,该表由我使用的四个 SQL 脚本中的所有列组成。如果可能的话......那么我可以在 OLE DB Source 的 SQL 命令中放置四个不同的脚本吗?即使在将放入 OLE DB 目标的表中创建所有列(在四个脚本中),它是否会在映射部分中引起混淆?

SQL 1:

Select r.ResourceID, r.SubSubFunctionCode, r.SubLocationCode, r.Site, SiteDesc, t.Resourceid, sum(ItemValue1) as HoursOutstanding, 
sum(ItemValue1 * isnull(case when itemvalue2 = 0 then CostRateRegOper else CostRateIntOper end,0)) 
as OperCostOutstanding,
sum(ItemValue1 * isnull(case when itemvalue2 = 0 then ChargeRateRegOper else ChargeRateIntOper end,0)) 
as OperRevenueOutstanding,
sum(ItemValue1 * isnull(case when itemvalue2 = 0 then CostRateRegHome else CostRateIntHome end,0)) 
as HomeCostOutstanding,
sum(ItemValue1 * isnull(case when itemvalue2 = 0 then ChargeRateRegHome else ChargeRateIntHome end,0)) 
as HomeRevenueOutstanding,
HomeCurrCode,
sum(ItemValue1 * isnull(case when itemvalue2 = 0 then CostRateRegNat else CostRateIntNat end,0)) 
as NatCostOutstanding,
sum(ItemValue1 * isnull(case when itemvalue2 = 0 then ChargeRateRegNat else CHargeRateIntNat end,0)) 
as NatRevenueOutstanding,
NatCurrCode
from ODS_Staff_Task t, ODS_CurrentResource r
where t.TaskTypeID in (5,6) --missing time
and R.RESOURCEID = T.RESOURCEID
and r.resourcetypecode <> 'C'
and t.sitedesc = r.resourcesite

SQL 2:

Select SiteDesc, t.Resourceid, sum(ItemValue1) as ExpenseToApprove from ODS_Staff_Task t
where t.TaskTypeID in (2) 
group by SiteDesc, t.Resourceid

SQL 3:

Select SiteDesc, t.Resourceid, sum(ItemValue1) as HoldsToRelease from ODS_Staff_Task t
where t.TaskTypeID in (3) 
group by SiteDesc, t.Resourceid

SQL 4:

Select SiteDesc, t.Resourceid, sum(ItemValue1) as MonthlyReviewsOutstanding from ODS_Staff_Task t
where t.TaskTypeID in (4) 
group by SiteDesc, t.Resourceid

非常感谢!

4

1 回答 1

0

我会尝试为每个 SELECT 语句使用一个 OLE DB 源,然后使用 UNION ALL 块来合并所有行。然后您可以将 UNION ALL 块中的列映射到您的目的地。不过,您最终会得到很多 NULL。由于并非所有列都存在于所有查询中。

于 2013-10-07T09:30:09.643 回答