Dear Grant
Thank you very much for your help.
I tried to rerun the codes as you instructed (please see Code 3 below). However, it still gave me only records that existed in both "oiradm.degrees_awarded" and "oiradm.student" tables although I had specified a right join. What I needed was all records from "oiradm.student" table (with filter conditions). Do you have any ideas on how I should modify the codes? Thank you very much.
-----------------------------
Code 3
select distinct stpidm
, styear
, stterm
, stcyt
, dadate
, shrtgpa_term_code
, sum(shrtgpa_hours_earned)
from oiradm.degrees_awarded A RIGHT JOIN oiradm.student ON dapidm = stpidm
LEFT JOIN saturn.shrtgpa ON stpidm = shrtgpa_pidm
where st1sttime = 'F'
and stlevel = 'UG'
and ststsch = 'AS'
and styear >= '2003'
and styear <= '2008'
and stterm = '40'
and dalevel = 'U'
and daschool = 'AS'
and dadate IN
(select min(B.dadate)
from oiradm.degrees_awarded B
where A.dapidm = B.dapidm
and A.dalevel = B.dalevel
and A.daschool = B.daschool
and A.dalevel = 'U'
and A.daschool = 'AS'
and B.dalevel = 'U'
and B.daschool = 'AS'
group by B.dapidm, B.dalevel, B.daschool
)
and shrtgpa_levl_code = 'UG'
group by stpidm, styear, stterm, stcyt, dadate, shrtgpa_term_code
-----------------------------