日期:2014-05-18  浏览次数:20573 次

求一个语句的写法
一张表A,样式如下:

fID                   fDate
--------------------------------------
001                   1900-01-01
001                   2003-05-04
002                   1900-01-01
002                   2007-03-04
002                   1900-01-01
...................


同一个fID号,把fDate为1900-01-01的更新为不是1900-01-01日期的

------解决方案--------------------
update 表A
set fDate=(select top 1 fDate from 表A AS T1 where T1.fid=表A.Fid and fdate <> '1900-01-01 ' )
where fdate= '1900-01-01 '
------解决方案--------------------

update m
set
fDate=n.fDate
from
表A m,
表A n
where
m.fID=n.fID and m.fDate= '1900-01-01 ' and n.fDate <> '1900-01-01 '