--A22:保险费,tbdt:投保日期,indt:进厂日期
--有买保险的记录
select a.name,case b.sex when '0' then '女' else '男' end sex ,
b.idcardNo as 身份证号, 用工性质='临时工' ,职工类别='在职', case when faddRess like '%东莞%' then '市内' else '市外' end 户口性质
,缴费工资='1030',企业养老='1',地方养老='1'
,机关养老='0',工伤='1' ,失业='1' ,生育='0' ,综合基本='0' , 住院基本='1',
住院补充='0' ,公务员='0' ,子女基本='0' ,门诊='0' ,
/* case when (tbdt is not null) then left(convert(varchar(8),cast(b.tbdt as datetime),112),6) else */
left(convert(varchar(8),dateAdd(month,1,b.indt),112),6) as 企业养老参保年月
from rs_salary_report_mx a,rs_person_1 b
where a.mon in('200808') and a.a22=87 and b.pnl=a.pnl /* and b.idcardNo is null */ order by a.deptNo,a.pnl
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/729024/viewspace-564884/ ,如需转载,请注明出处,否则将追究法律责任。