select a.*,b.* from #temppd a left join #tempbom b on a.item_code=b.item_code 这句代码 还可以加第三个表嘛?
怎么加。
这里只有两个表对比。但是我想在这段代码里面加上第三个表对比请问怎么加?
我试了很久都没结果!
求答案!
怎么加。
这里只有两个表对比。但是我想在这段代码里面加上第三个表对比请问怎么加?
我试了很久都没结果!
求答案!
inner join
right join不清楚楼主要什么样的结果
from #temppd a
left join #tempbom b on a.item_code=b.item_code
left join 第三个表 c on xxx=xxx具体要看你第三个表是怎么关联的
on a.item_code=b.item_code
left join #tempnew c
on a.item_code=c.item_code
select a.mater_code,a.pdwet,c.jieguo as gxwet,a.mtwet,a.mtgmawet,b.item_order from
(select a.mater_code,sum(case when TAG='A' then wet else 0 end) as pdwet,
sum(case when TAG='包根' then wet else 0 end) as gxwet,
sum(case when TAG='GC' then wet else 0 end) AS mtwet,
sum(case when TAG='GMA' then wet else 0 end) AS mtGMAwet
from
(select b.mater_code,sum(round(a.wet*b.len_xs,2)) as wet,tag from #temppd a left join #tempbom b on a.item_code=b.item_code
where b.class_code=2 and b.mater_code is not null group by b.mater_code,a.tag
union all
select b.mater_code,sum((a.wet*b.len_xs/100)) as wet, '包根' AS tag from #temppd_gx a left join tempbom b on a.item_code=b.item_code
where b.class_code=1 and b.mater_code is not null group by b.mater_code
union all
select item_code as mater_code,wet,packno AS tag from #temppd_mt
) a group by a.mater_code,a.tag
)a left join fourk.dbo.item b on a.mater_code=b.item_code
order by item_order
那我这段代码怎么加!我 c.jieguo as gxwet
这个C 我想加个表!
但是不知道怎么加上去
这是储存过程!
on a.item_code=b.item_code
left join #tempnew c
on a.item_code=c.item_code