sql - Sum function is multiplied by 4 -


i have put in following code sum values in polin.qtyremn , oelin.otyord. works, instead of summing values, multiplying quantities 4 , adding them. think being caused joins , calling value 4 times , adding them.

select polin.itemkey, polin.description, polin.location, inloc.qtyonhand, sum(polin.qtyremn), sum(oelin.qtyord) x.dbo.inloc inloc, x.dbo.oelin oelin, x.dbo.polin polin inloc.itemkey = polin.itemkey , inloc.itemkey = oelin.itemkey , inloc.location = polin.location , inloc.location = oelin.location , ((polin.location='spl') , (polin.qtyremn>0)) group polin.itemkey, polin.description, polin.location, inloc.qtyonhand order polin.itemkey 

i believe it's because you're not summing qtyonhand -- if undersatnd correctly, number... don't want group it... want sum it... see below.. should resolve issue of duplicates...

select  polin.itemkey, polin.description, polin.location,          sum(inloc.qtyonhand) [qtyonhand], sum(polin.qtyremn) [qtyremn], sum(oelin.qtyord) [qtyord] x.dbo.inloc inloc, x.dbo.oelin oelin, x.dbo.polin polin inloc.itemkey = polin.itemkey , inloc.itemkey = oelin.itemkey , inloc.location = polin.location , inloc.location = oelin.location , ((polin.location='spl') , (polin.qtyremn>0)) group polin.itemkey, polin.description, polin.location order polin.itemkey 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -