假设我有四个不同的脚本,并且所有列都将用于创建Fact表,如果我将这四个脚本粘贴到OLE DB Source中的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
非常感谢!
博
答案 0 :(得分:0)
我尝试为每个SELECT语句使用一个OLE DB源,然后使用UNION ALL块来合并所有行。然后,您可以将UNION ALL块中的列映射到目标。但是你最终会得到很多NULL。由于并非所有列都存在于所有查询中。