本帖最后由 maoweiting19910402 于 2012-04-13 16:31:51 编辑

解决方案 »

  1.   

    列一下你想要的结果,name是指人姓名吗?
      

  2.   

    SQL> update b set last=
      2  (select max(a.money) from b a where a.tim < b.tim and a.what is not null and a.what <> 0 and b.name=a.name)
      3  /
     
    6 rows updated
     
    SQL> select * from b;
     
          NAME PLACE                TIM         WHAT                      MONEY       LAST
    ---------- -------------------- ----------- -------------------- ---------- ----------
             1 超市                 2012/4/13   1                            12         13
             1 超市                 2012/4/11   1                            13 
             1 超市                 2012/4/10   0                            14 
             2 学校                 2012/4/7    1                            16 
             2 学校                 2012/4/16   1                            31         16
             2 学校                 2012/4/26   1                            12         31
     
    6 rows selected
      

  3.   

    update b set last=
    (select max(a.money) from b a where a.tim=(select max(c.tim) from b c where c.tim<b.tim and c.what <> 0)
     and a.what is not null  and b.name=a.name and a.place=b.place)
    /