Hi
CREATE TABLE #temp(sr_No int ,remarks nvarchar(150),Particulars nvarchar(100),
opening numeric(19,6),receipt numeric(19,6), issue numeric(19,6),closing numeric(19,6))
insert into #temp select ROW_NUMBER() OVER (ORDER BY opening) ,'','', sum(outqty), 0 , 0 , 0 from oinm t0 where t0.docdate < '12/1/2010'
insert into #temp select ROW_NUMBER() OVER (ORDER BY opening) ,'',warehouse, 0, sum(inqty) , 0 , 0 from oinm t0 where t0.docdate >=
'12/1/2010' and t0.docdate <= '12/31/2010' group by warehouse
select sr_no,(remarks),particulars 'Particulars',sum(opening)'Opening',sum(receipt)'Receipt',sum(issue)'Issued',(sum(Opening)+sum(Receipt))-Sum(Issue)'Closing' from #temp
group by sr_no,remarks,particulars
drop table #temp
In this query i want to autogenerate serial no and then Grand Total
Thanks