Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2695

Re: Problem with Query Max/Mix Values in Warehouses

$
0
0

Hi Krystian,

 

Try this query, it will show only values > 0 for the agregate of minStock:

 

Select

t0.ItemCode [Kod Produktu],

t1.ItemName [Nazwa towaru],

sum (t0.OnHand) [W magazynie],

sum (t0.onorder) [Zamowione],

sum (t0.iscommited) [potwierdzone],

sum(isnull(t0.MinStock,0)) [Min],

sum (isnull(t0.MaxStock,0)) [Max],

sum ((t0.OnHand-isnull(t0.minStock,0))*(-1))[niedobor do min] ,

case

  when sum(isnull(t0.MaxStock,0))=0 then 0

  else sum (( t0.OnHand-isnull(t0.MaxStock,0))*(-1))

end [niedobor do max]

from OITW t0

join oitm t1 on t1.ItemCode=t0.ItemCode

where t0.WhsCode IN ('wyr', 'mz1','mz2','mz3','mz4')

GROUP BY t0.itemcode, t1.ItemName

HAVING sum(isnull(t0.MinStock,0)) > 0

 

hope this helps,

 

juanpa


Viewing all articles
Browse latest Browse all 2695

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>