I was tasked with finding the enrollment status for each status for the past 3 years. some students have more that 4 records. I am trying to exclude graduated students. Any help would be appreciated. here is my code.
select distinct a.People_code_id, p.last_name,p.first_name,left(a.ADMIT_DATE,11) as "Admit Date",
a.ENROLL_SEPARATION,s.last_year,s.last_term,a.graduated,a.GRADUATED_YEAR,pp.PhoneNumber
from academic A
left join people p on p.people_code_id=a.PEOPLE_CODE_ID
left join transcriptdetail T on t.PEOPLE_CODE_ID = a.PEOPLE_CODE_ID
left join student s on s.people_code_id=a.PEOPLE_CODE_ID
left join personphone pp on pp.personid=p.PersonId
where A.academic_year >= '2019' and A.GRADUATED ='N' and
CREDITS > 0 and PRIMARY_FLAG='Y' and ACADEMIC_FLAG='Y' order by LAST_NAME