Hi Devraj,
Try this below query,
Note: Where ever i mentioned 'WIP01' change it to your production warehouse
and 'RM01' change it to your stores warehouse.
Let me know your feedback.
select Tbl1.ItemCode,Tbl1.FromWhsCod,Tbl1.[Production Whs],SUM(Tbl1.[Stores Qty]) [Stores Qty],SUM(tbl1.[Production Qty]) [Production Qty]
from (
select r2.ItemCode,r2.FromWhsCod,'WIP01' [Production Whs],sum(r2.Quantity) [Stores Qty], 0 [Production Qty]
from OWTR R1 inner join WTR1 R2 on r1.DocEntry = r2.DocEntry
where r2.FromWhsCod in ('RM01')
group by
r2.ItemCode,r2.FromWhsCod,r2.WhsCode
union all
select r2.ItemCode,'RM01',r2.FromWhsCod,0,sum(r2.Quantity) [Qty]
from OWTR R1 inner join WTR1 R2 on r1.DocEntry = r2.DocEntry
where r2.FromWhsCod in ('WIP01')
group by
r2.ItemCode,r2.FromWhsCod,r2.WhsCode) Tbl1
group by Tbl1.ItemCode,Tbl1.FromWhsCod,Tbl1.[Production Whs]