Hi
CREATE TABLE #temp(Particulars nvarchar(100),opening numeric(19,6),receipt numeric(19,6), issue numeric(19,6),closing numeric(19,6))
insert into #temp select ' ',(sum(inqty)-SUM(outqty)),0 , 0,0 from oinm t0 where t0.docdate < [%0] and t0.itemcode = 'Trays' and warehouse = 'PROD' group by warehouse
insert into #temp select warehouse,0,sum(outqty),0 , 0 from oinm t0 where t0.docdate >= [%0] and t0.docdate <= [%1] and t0.itemcode = 'A' and warehouse != 'PROD' group by warehouse
insert into #temp select warehouse,0,0,sum(inqty),0 from oinm t0 where t0.docdate >= [%0] and t0.docdate <= [%1] and t0.itemcode = 'A' and warehouse != 'PROD' group by warehouse
select (particulars) 'Particulars',opening'Opening',receipt'Receipt',issue'Issued',0 from #temp
I want Grand Total of Opening , Receipt , Issue in the end.
Thanks