i am using sql server 2008.
i am calculating envetory as FIFO method like in tally.
please go through
http://accountingexplained.com/financial/inventories/fifo-method
i have table as
create table #Stock ( StoreId int, ProductId int, Transection_Date Date, transectionType varchar(20), Unit numeric(18,2), UnitCost numeric(18,2) )
insert into #Stock select 1,201, '2014-03-01', 'Beginning Inventory', 68, 14
insert into #Stock select 1,201,'2014-03-05', 'Purchase', 140, 15.50
insert into #Stock select 1,201,'2014-03-09', 'Issue', 94, 0
insert into #Stock select 1,201,'2014-03-11', 'Purchase', 40, 16
insert into #Stock select 1,201,'2014-03-16', 'Purchase', 68, 14
insert into #Stock select 1,201,'2014-03-20', 'Issue', 116, 0
insert into #Stock select 1,201,'2014-03-29', 'Issue', 62, 0
select * from #Stock drop table #Stock
i am looking sql function or store procedure which will accept parameter fromDate,toDate and sorteId
and display as given format
How about: