I am trying to pull only the most recent forms received of the 4 types - ('DHAPCALC','DHAPAGRMT','D
) but for some reason when I add in the max(date) lines below I lose several.
SELECT distinct decode(question_answer.callout_id, '29','JFO','30','NPSC'),
trunc(SUBST.RCVD_DT), subst.long_desc, t.last_nm
SUBST, question_answer, rgsn_sts, rgst t
( RGSN.DSTR_NR=SUBST.DSTR_NR and RGSN.RGSN_ID=SUBST.RGSN_ID )
( RGSN.DSTR_NR=T.DSTR_NR and RGSN.RGSN_ID=T.RGSN_ID )
(rgsn.dstr_nr = question_answer.dstr_nr and rgsn.rgsn_id = question_answer.rgsn_id)
and (rgsn.dstr_nr = rgsn_sts.dstr_nr and rgsn.rgsn_id = rgsn_sts.rgsn_id)
RGSN.DSTR_NR = 4085
RGSN.RGSN_ID IN (393930088,
//MY PROBLEM WITH THE CODE IS HERE!
and SUBST.SUBST_TYPE_CD in ('DHAPCALC','DHAPAGRMT','DHAPPIINOTE','RECREQ'))
and SUBST.RCVD_DT =
where rgsn_id = rgsn.rgsn_id
and SUBST_TYPE_CD in ('DHAPCALC','DHAPAGRMT','DHAPPIINOTE','RECREQ'))