首页 > 代码库 > 【数据处理】大库订货数据匹配

【数据处理】大库订货数据匹配

select  distinct a.商品编码,a.品名,a.规格,a.最终进价 大库价格,c.curcsprc 进价,a.最终进价-c.curcsprc 差价,d.qty 西部,e.qty 东部,f.qty 中区
from lhdh201408 a
left join lhspm b on a.商品编码=b.pluid
left join 商品码 c on b.barcode=c.bcd
left join (select pluno,sum(qty) qty from xbxs where rq between ‘20140501‘ and ‘20140801‘ group by pluno ) d on c.pluno=d.pluno
left join (select pluno,sum(qty) qty from dbxs where rq between ‘20140501‘ and ‘20140801‘ group by pluno ) e on c.pluno=e.pluno
left join (select pluno,sum(qty) qty from zqxs where rq between ‘20140501‘ and ‘20140801‘ group by pluno ) f on c.pluno=f.pluno
order by 2