SELECT  user_id userId, pid pjtId,departid deptId,yearmonth,pmId,datum_attendance_date datumWorkDuration,actual_attendance_date attendanceDuration,
convert(actual_attendance_date/datum_attendance_date*100,decimal(10,2)) attendanceRate
FROM(
	SELECT uat.id,uat.user_id,uat.pid,uat.departid,uat.yearmonth,uat.datum_attendance_date,uat.actual_attendance_date,d.dept_proj_managerid pmId
	from t_bus_user_attendance_total uat
	LEFT JOIN t_s_depart d
	ON uat.pid = d.ID
) uat
WHERE uat.yearmonth =:yearmonth AND uat.pid != ''