(select kqz.name from kqgl_main_kqz kqz where kqz.id = sum.att_group) as attname,
IFNULL(rtj.attdate, '') attdate,
IFNULL(rtj.userid,'') userid,
IFNULL(rtj.data,'') data,
IFNULL(rtj.sbdk1,'') sbdk1,
IFNULL(rtj.sbdk1jg,'') sbdk1jg,
IFNULL(rtj.xbdk1 ,'') xbdk1,
IFNULL(rtj.xbdk1jg,'') xbdk1jg,
IFNULL(rtj.sbdk2 ,'') sbdk2,
IFNULL(rtj.sbdk2jg ,'') sbdk2jg,
IFNULL(rtj.xbdk2 ,'') xbdk2,
IFNULL(rtj.xbdk2jg,'') xbdk2jg,
IFNULL(rtj.sbdk3 ,'') sbdk3,
IFNULL(rtj.sbdk3jg ,'') sbdk3jg,
IFNULL(rtj.xbdk3,'') xbdk3,
IFNULL(rtj.xbdk3jg ,'') xbdk3jg,
IFNULL(rtj.ydkcs ,'') ydkcs,
IFNULL(rtj.gzsc ,'') gzsc,
IFNULL(rtj.qyid,'') qyid,
IFNULL(rtj.dksj ,'') dksj,
IFNULL(rtj.yzcdcs ,'') yzcdcs,
IFNULL(rtj.yzcdsc ,'') yzcdsc,
IFNULL(rtj.kgcdfzs,'') kgcdfzs,
sum.days_on_duty as daysonduty,
sum.days_off as daysoff,
sum.length_business_trip as lengthbusinesstrip,
sum.time_out as timeout,
sum.total_overtime_hours as totalovertimehours,
sum.working_turn_compen_leave as workingturncompenleave,
sum.rest_turn_compen_leave as restturncompenleave,
sum.holiday_turn_compen_leave as holidayturncompenleave,
sum.working_transfer_overtime as workingtransferovertime,
sum.rest_transfer_overtime as resttransferovertime,
sum.holiday_transfer_overtime as holidaytransferovertime,
mrtj.leaverulesid,
mrtj.duration as balancedays
from kqgl_asso_month_punch_summary sum
LEFT JOIN (
select DISTINCT info.`name` as username ,
dkjl.attdate,
bcsz.`name` as bcname,bcsz.sbdk1 as bcsbdk1,bcsz.xbdk1 as bcxbdk1,bcsz.sbdk2 as bcsbdk2,bcsz.xbdk2 as bcxbdk2,bcsz.sbdk3 as bcsbdk3,bcsz.xbdk3 as bcxbdk3,