Skip to Content
0
Former Member
Feb 15, 2011 at 03:53 PM

Query

22 Views

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