1
FromDate        ToDate        TempDate
2011-05-03      2011-08-02    NULL
2011-06-03      2011-08-02    2011-05-03
2007-09-30      2009-09-30    2011-06-03 

我在 SQL Server 中有一个表,并且希望列TempDate具有前一行的值FromDate

4

1 回答 1

0
UPDATE tab SET
    Tempdate = (SELECT Max(FromDate) 
                FROM Tab t2 
                WHERE t2.Fromdate < tab.FromDate )
于 2012-12-25T08:35:10.990 回答