1、员工表按性别,生日生成退休日期,及对应的延退月份(企业没女干部,请参考男女退休)
SELECT id,
gender, --性别
birthdate,--生日
CASE gender
WHEN '男' THEN DATEADD(MM, 60 * 12 + case when 36 < CEILING((DATEDIFF(mm,'1965-01-01',birthdate) + 1) / 4.0) then 36 when CEILING((DATEDIFF(mm,'1965-01-01',birthdate) + 1) / 4.0) <= 0 then 0 else CEILING((DATEDIFF(mm,'1965-01-01',birthdate) + 1) / 4.0) end, birthdate)
WHEN '女' THEN DATEADD(MM, 50 * 12 + case when 60 < CEILING((DATEDIFF(mm,'1975-01-01',birthdate) + 1) / 2.0) then 60 when CEILING((DATEDIFF(mm,'1975-01-01',birthdate) + 1) / 2.0) <= 0 then 0 else CEILING((DATED