I am trying to avoid duplicate records. I want sql to pull anyone who has a ('AU','RE', 'RW') record but I only need one to show in my results. Can you use Decode or Nvl for something like this?
select distinct r1.sfrstcr_rsts_code, spriden_last_name, spriden_first_name, s1.saradap_appl_date, s1.saradap_appl_no
from saradap s1, sfrstcr r1, spriden
where spriden_pidm = sfrstcr_pidm
and spriden_pidm = saradap_pidm
and s1.saradap_appl_no = (select max( s2.saradap_appl_no)
from saradap s2
where s2.saradap_pidm = s1.saradap_pidm)
and sfrstcr_pidm (+) = saradap_pidm
and saradap_term_code_entry = sfrstcr_term_code
and r1.sfrstcr_rsts_code in ('AU','RE', 'RW')
and r1.sfrstcr_reg_seq = (select max (r2.sfrstcr_reg_seq)
from sfrstcr r2
where r2.sfrstcr_reg_seq = r1.sfrstcr_reg_seq)
AND saradap_term_code_entry = 202210
--and stvmajr_code = saradap_term_code_entry
order by spriden_last_name