SELECT a.emplid , a.institution , COUNT(*) FROM ps_ssr_apt_hdr a , PS_ACAD_PROG c WHERE c.ssr_apt_instance <> 0 AND c.prog_status = 'AC' AND c.emplid = a.emplid AND c.institution = a.institution AND c.ssr_apt_instance <> a.ssr_apt_instance AND c.effdt = ( SELECT MAX(c1.effdt) FROM PS_ACAD_PROG c1 WHERE c1.emplid = c.emplid AND c1.acad_career = c.acad_career AND c1.stdnt_car_nbr = c.stdnt_car_nbr AND c1.effdt <= %CurrentDateIn) AND c.effseq = ( SELECT MAX(c2.effseq) FROM PS_ACAD_PROG c2 WHERE c2.emplid = c.emplid AND c2.acad_career = c.acad_career AND c2.stdnt_car_nbr = c.stdnt_car_nbr AND c2.effdt = c.effdt) GROUP BY a.emplid, a.institution
|