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

Re: Sum function in warehouse query

$
0
0

Hi,

 

Try this:

 

select t0.ItemCode [Product Code], t1.ItemName [Item Name], SUM(t0.OnHand) [In Magazine], sum(isnull(t0.MinStock,0)) [Min],SUM(isnull(t0.MaxStock,0)) [Max],

SUM((t0.OnHand-isnull(t0.minStock,0))*(-1))[Value to Min] , SUM(case when isnull(t0.MaxStock,0)=0 then 0

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

[Value to Max ] from OITW t0

inner join oitm t1 on t1.ItemCode=t0.ItemCode

where t0.WhsCode IN ('wyr','cze') and (t0.MinStock>0 )

 

 

group by t0.ItemCode , t1.ItemName

 

Thanks.


Viewing all articles
Browse latest Browse all 9129

Trending Articles