30天100个员工的考勤记录,有缺卡的补0,
select b.date,re.userName,k.* from( select convert(varchar(10),dateadd(day,-number,‘2021-03-25’),120) as [date] from master…spt_values
where number<30 and number>=0 and type=‘p’)b
left JOIN 人资 re on re.userid >0 and re.del=0 and re.sorce=12
left join 考勤 k on re.userbh=k.ddid and b.date= k.inDate
order by re.userid,b.date