When I run this, the error message is command not properly ended. I haven't done update queries in Oracle, have done them in Access using the graphical interface, so probably haven't written correctly. Trying to update the decision and date by only selecting one record from the decision table which has the decision date less than the cutoff date specified by a date in the cutoff table.
Code:
UPDATE APP_STAT a
SET a.DECISION = ad.DECISION, a.DECISION_DATE = ad.DECISION_DATE
LEFT JOIN
(SELECT *
FROM (SELECT decision.*,
ROW_NUMBER () OVER (PARTITION BY person_uid ORDER BY decision_date DESC, decision_number DESC)
dt
FROM mst_admissions_decision decision, sxschech.CUTOFF
WHERE decision_date IS NOT NULL AND decision_date <= cutoff_dt
--and academic_period in ('200830','200840')
)
WHERE dt = 1
) ad
ON a.APPLICATION_NUMBER = ad.APPLICATION_NUMBER
AND a.ACADEMIC_PERIOD = ad.ACADEMIC_PERIOD
--AND a.Academic_period in ('200830','200840')
AND a.person_uid = ad.PERSON_UID;