通过死亡日期和退休年龄计算年龄方面的问题 [英] problem in calculating age via date of death and age at do retirement

查看:178
本文介绍了通过死亡日期和退休年龄计算年龄方面的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此查询在END处产生错误,任何人都可以帮助我吗?


this query generates error at END, anyone can help me?


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!=''

推荐答案

( datediff(year , [Birth date], [Date of Retirement])


括号是否不平衡?


Unbalanced parentheses by any chance?


更新语法: http://msdn.microsoft.com/en-us/library/ms177523.aspx [ ^ ]
Update syntax:http://msdn.microsoft.com/en-us/library/ms177523.aspx[^]
UPDATE yourTableName
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!=''


这篇关于通过死亡日期和退休年龄计算年龄方面的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆