数量累加问题
各位好,小弟有一问题请教,表如下:
declare @a table
(
	fbqty		int,
	finqty		int,
	foutqty	int
)
insert into @a
select 100, 20, 30
union all
select 0, 50, 20
union all
select 0, 200, 150
union all
select 0, 100, 250
想得到结果:
fbqty       finqty      foutqty     
----------- ----------- ----------- 
100         20          30
90           50          20
120          200         150
170           100         250
也就是除第一条纪录外,后面的纪录的fbqty都是前一条纪录的fbqty+finqty-foutqty
谢谢各位!
              
------解决方案--------------------
加个自增列就行