(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = b.bmgw_id limit 1) limit 1) as bm_name,
SUM((CASE WHEN c.sts = 3 THEN 1 ELSE 0 END)) AS archivedPNum,
SUM((CASE WHEN c.sts in (0,1,2) THEN 1 ELSE 0 END)) AS underwayPNum,
(SELECT name FROM jxgl_performance_appraisal WHERE id = a.performance_appraisal_id ORDER BY create_time DESC LIMIT 1 ) recentlyProject,
(SELECT comprehensive_score FROM jxgl_appraisal_assessment WHERE type = 1 AND appraisal_id in (SELECT id FROM jxgl_appraisal WHERE emp_num = a.emp_num) ORDER BY create_time DESC LIMIT 1 ) recentlyScore,
(SELECT level FROM jxgl_appraisal_assessment WHERE type = 1 AND appraisal_id in (SELECT id FROM jxgl_appraisal WHERE emp_num = a.emp_num) ORDER BY create_time DESC LIMIT 1 ) recentlyLevel
FROM jxgl_appraisal a
LEFT JOIN yggl_main_emp b ON a.emp_num = b.emp_num AND b.org_code = #{param.orgCode}
LEFT JOIN jxgl_performance_appraisal c ON a.performance_appraisal_id = c.id
<!-- 缺部门 搜索 -->
<where>
<iftest="param.query != null and param.query != ''">