不好意思,是字段值,也就是说:
  c2=c1+a2-b2
  c3=c2+a3-b3
  c4=c3+a4-b4
   ...
 

解决方案 »

  1.   

    不好意思,是不是我说得不明白呢?也就是说a b c 三个字段,当前c的值等前一个c的
    值加a减b
      

  2.   

    下面是我的一些愚见,因为我是新手,所以难免有错,大家见笑了。
    create procedure proc_t
    @a_temp float(10),@b_temp float(10)
    as
    if exists (select * from t)
    begin
    delcare @c_temp float(10)
    select c from t into @c_temp order by primary_id ascinsert into t values
    (@a_temp,@b_temp,@c_temp+@a_temp-@c_temp)
    end
      

  3.   

    select fid=identity(int,1,1),* into #temp from 表T
    select T.a as 本日进货 ,T.b as 本日发货 ,(select c from #temp where fid=T.fid-1)+a-b  as 本日库存
    from #temp Tdrop #temp