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
的值
答案 0 :(得分:0)
UPDATE tab SET
Tempdate = (SELECT Max(FromDate)
FROM Tab t2
WHERE t2.Fromdate < tab.FromDate )