Hi
select t2.itemcode,isnull((select (sum(t0.cmpltqty) * Case t2.sweight1 When 0 Then 1 ELSE t2.sweight1 END)
from owor t0 where t0.postdate >= [%0] and t0.postdate <= [%1] and t0.itemcode = t2.itemcode and t0.warehouse = 'PROD' and t0.type = 'S' and t0.status = 'R' ),0) from oitm t2 where (t2.itmsgrpcod = 123 or t2.itmsgrpcod = 138) and t2.qrygroup62 = 'Y' group by t2.itemcode ,t2.sweight1
order by (t2.itemcode)
It should multiply t2.sweight1 only if itemgroup code = 138
Thanks