SET
Age =
(
CASE WHEN (not [Date of Death] is null)
THEN datediff(year, [Birth date], [Date of Death] )
ELSE
( datediff(year , [Birth date], [Date of Retirement])
END
)
WHERE
PID!=''
回答
评论会员:理查德MacCutchan 时间:2012/02/04
{C}不平衡括号中的任何机会
评论会员:游客 时间:2012/02/04
?Prerak帕特尔 更新语法:
UPDATE yourTableName
SET Age =
(
CASEWHEN (not [Date of Death] isnull)
THEN datediff(year, [Birth date], [Date of Death] )
ELSE
( datediff(year , [Birth date], [Date of Retirement])
END
)
WHERE
PID!=''