select a.ordicode,a.cgicode,a.purinvicode,a.cgcode,a.othergattr1,(nvl(b.sumqtp,0)-nvl(d.sumqtp,0)) ztqtp,(nvl(c.sumqtp,0)-nvl(d.sumqtp,0)) zkqtp from
(select m.slcode,g.ordicode,g.cgicode,g.purinvicode,g.cgcode,g.othergattr1 from storeslist m,storeslistg g where m.islcode=g.islcode and m.sheetcode='1210821' group by g.ordicode,g.cgicode,g.purinvicode,g.cgcode,g.othergattr1) a
/**在保稅區**/
left join
(select g.ordicode,g.cgicode,g.purinvicode,g.cgcode,g.othergattr1,sum(g.qtp) sumqtp from storeslist m,storeslistg g where m.islcode=g.islcode and m.sheetcode='1210821' and g.scode like '400%' and m.status>='70' and g.sdc=1 group by g.ordicode,g.cgicode,g.purinvicode,g.cgcode,g.othergattr1) b
on a.ordicode=b.ordicode and a.cgicode=b.cgicode and a.purinvicode=b.purinvicode and a.cgcode=b.cgcode and a.othergattr1=b.othergattr1
/**在第三方倉庫**/
left join
(select g.ordicode,g.cgicode,g.purinvicode,g.cgcode,g.othergattr1,sum(g.qtp) sumqtp from storeslist m,storeslistg g where m.islcode=g.islcode and m.sheetcode='1210821' and g.scode like '300%' and m.status>='70' and g.sdc=1 group by g.ordicode,g.cgicode,g.purinvicode,g.cgcode,g.othergattr1) c
on a.ordicode=c.ordicode and a.cgicode=c.cgicode and a.purinvicode=c.purinvicode and a.cgcode=c.cgcode and a.othergattr1=c.othergattr1
/**發貨**/
left join
(select g.ordicode,g.cgicode,g.purinvicode,g.cgcode,g.othergattr1,sum(g.qtp) sumqtp from salshiporder m,storeslistg g where m.salshipicode=g.mainicode and m.status>='70' and m.sheetcode='1215621' group by g.ordicode,g.cgicode,g.purinvicode,g.cgcode,g.othergattr1) d
on a.ordicode=d.ordicode and a.cgicode=d.cgicode and a.purinvicode=d.purinvicode and a.cgcode=d.cgcode and a.othergattr1=d.othergattr1
group by a.ordicode,a.cgicode,a.purinvicode,a.cgcode,a.othergattr1
uj5u.com熱心網友回復:
去掉最后一行group by a.ordicode,a.cgicode,a.purinvicode,a.cgcode,a.othergattr1
uj5u.com熱心網友回復:
你的陳述句沒有分組函式,不需要用group by啊uj5u.com熱心網友回復:
也沒有看到你的SELECT子句中有用聚合函式?轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/116416.html
標籤:基礎和管理
上一篇:緬甸文的全文索參考什么lexer
下一篇:ORACLE 底層介面
