684
社区成员
发帖
与我相关
我的任务
分享declare @sql nvarchar(3000)
set @sql='select *,(eCostPrice+hCostPrice+mCostPrice) as TotalCostPrice from (select isnull(A.Batch,B.Batch) as Batch,isnull(A.MOID,B.MOID) as MOID,isnull(A.Date,B.Date) as Date,isnull(A.PMCPlanner,B.PMCPlanner) as PMCPlanner,isnull(A.PMCPlannerName,B.PMCPlannerName) as PMCPlannerName,isnull(A.eCostPrice,0) as eCostPrice,isnull(A.hCostPrice,0) as hCostPrice,isnull(B.mCostPrice,0) as mCostPrice from (select isnull(A.Batch,B.Batch) as Batch,isnull(A.MOID,B.MOID) as MOID,isnull(A.Date,B.Date) as Date,isnull(A.PMCPlanner,B.PMCPlanner) as PMCPlanner,isnull(A.PMCPlannerName,B.PMCPlannerName) as PMCPlannerName,A.eCostPrice,B.hCostPrice from #t_equ_cost A full outer join #t_hum_cost B on A.Batch=B.Batch) A full outer join #t_met_cost B on A.Batch=B.Batch) A'
print(@sql)
/*select *,
(eCostPrice+hCostPrice+mCostPrice) as TotalCostPrice
from (select isnull(A.Batch,B.Batch) as Batch,isnull(A.MOID,B.MOID) as MOID,
isnull(A.Date,B.Date) as Date,isnull(A.PMCPlanner,B.PMCPlanner) as PMCPlanner,
isnull(A.PMCPlannerName,B.PMCPlannerName) as PMCPlannerName,
isnull(A.eCostPrice,0) as eCostPrice,isnull(A.hCostPrice,0) as hCostPrice,
isnull(B.mCostPrice,0) as mCostPrice from (select isnull(A.Batch,B.Batch) as Batch,
isnull(A.MOID,B.MOID) as MOID,
isnull(A.Date,B.Date) as Date,
isnull(A.PMCPlanner,B.PMCPlanner) as PMCPlanner,
isnull(A.PMCPlannerName,B.PMCPlannerName) as PMCPlannerName,
A.eCostPrice,B.hCostPrice from #t_equ_cost A
full outer join #t_hum_cost B on A.Batch=B.Batch) A
full outer join #t_met_cost B on A.Batch=B.Batch) A*/