SELECT a.supervisor_id , a.supervis_empl_rcd , a.emplid , a.empl_rcd , COUNT(DISTINCT a1.emplid %Concat %Cast(a1.empl_rcd,number, character) ) FROM ps_hr_direct_rep_5 a , ps_hr_direct_rep_5 a1 , PS_JOB B WHERE a.drill_down_flag = 'Y' AND a.hr_dr_level = 1 AND a.supervisor_flag = 'Y' AND a.emplid = A1.supervisor_id AND a.empl_rcd = A1.supervis_empl_rcd AND a1.drill_down_flag = 'Y' AND A1.hr_dr_level = 1 AND b.per_org IN ('EMP','CWR') AND A1.EMPLID = B.EMPLID AND A1.EMPL_RCD = B.EMPL_RCD AND A1.JOB_EFFDT = B.EFFDT AND B.EFFSEQ = ( SELECT MAX(JB2.EFFSEQ) FROM PS_JOB JB2 WHERE JB2.EMPLID = B.EMPLID AND JB2.EFFDT = B.EFFDT AND JB2.EMPL_RCD = B.EMPL_RCD) GROUP BY a.supervisor_id , a.supervis_empl_rcd ,a.emplid ,a.empl_rcd
|