SELECT DBO.YGB.YGBM, DBO.YGB.YGXM, DBO.YGB.YGXB, Dbo.ygb.ygmz, Dbo.ygb.sfid, dbo.ygb.zzmm, DBO.YGB.YGSR,Year ( GETDATE ()) – Year (DBO.YGB.YGSR) as YGNL,
DBO.YGB.GZSJ,Case if ygxb = ' 1 ' then DATEDIFF (day, GETDATE (), DATEADD (year, year, YGSR)) When ygxb = ' 0 ' and yglb = ' cadre ' then DATED IFF (Day, GETDATE (),
DATEADD (year, year, YGSR)) When ygxb = ' 0 ' and yglb = ' worker ' then DATEDIFF (day, GETDATE (), DATEADD (year, all, YGSR)) END as Ntts,Dbo.ygb.byxx, DBO.YGB.YGXL,
DBO.XLB.XLMC, Dbo.ygb.ygzc, DBO.ZCB.ZCMC, Dbo.ygb.ygjn, DBO.JNB.JNMC, DBO.YGB.YGZW, DBO.ZWB.ZWMC, DBO.YGB.LXDH, DBO.YGB.GZGW, DBO.YGB.YGLB, Dbo.ygb.memo,
DBO.VW_YGQKB.QKMC, Dbo.vw_ygqkb.tqts, DBO.VW_YGQKB.SHJG
From Dbo.xlb INNER JOIN
DBO.YGB on dbo.xlb.xlbm = DBO.YGB.YGXL INNER JOIN
DBO.ZCB on dbo.ygb.ygzc = DBO.ZCB.ZCBM INNER JOIN
DBO.JNB on dbo.ygb.ygjn = DBO.JNB.JNBM INNER JOIN
DBO.ZWB on dbo.ygb.ygzw = DBO.ZWB.ZWBM left OUTER JOIN
DBO.VW_YGQKB on DBO.YGB.YGBM = DBO.VW_YGQKB.YGBM
SQL Server based on date of birth, gender, age of identity, time to retire