Hi
What is wrong with this query
CREATE TABLE #temp(Particulars nvarchar(100),opening numeric(19,6),receipt numeric(19,6), issue numeric(19,6),closing numeric(19,6))
select
insert into #temp select ' ',(sum(inqty)-SUM(outqty)),0 , 0,0 from oinm t0 where t0.docdate < '1/1/2011' and t0.itemcode = t1.itemcode and warehouse = 'PROD' group by warehouse
insert into #temp select warehouse,0,sum(outqty),0 , 0 from oinm t0 where t0.docdate >= '1/1/2011' and t0.docdate <= '1/31/2011' and t0.itemcode = t1.itemcode and warehouse != 'PROD' group by warehouse
insert into #temp select warehouse,0,0,sum(inqty),0 from oinm t0 where t0.docdate >= '1/1/2011' and t0.docdate <= '1/31/2011' and t0.itemcode = t1.itemcode and warehouse != 'PROD' group by warehouse
from oitm where u_classification in('A','B')
select (particulars) 'Particulars',opening'Opening',receipt'Receipt',issue'Issued',0 from #temp
Thanks