Du kan "rangere" forskellige statusser baseret på din logik og derefter vælge den seneste status ud af dem. Du kan bruge logikken, der ligner den nedenfor, som presser alle "afvisninger".
Sørg for, at du inkluderer alle andre mulige statusser, hvis du bekymrer dig om ordren for resten af dem.
with t1 as
( select 1 id, 'Waiver Requested' status from dual union all
select 1 id, 'Rejected' status from dual union all
select 2 id, 'Waiver Requested' status from dual union all
select 2 id, 'Waiver Requested' status from dual union all
select 3 id, 'Rejected' status from dual union all
select 3 id, 'Rejected' status from dual union all
select 4 id, 'Waiver Requested' status from dual union all
select 4 id, 'Cancelled' status from dual
)
select id,
status,
max(status) KEEP (DENSE_RANK FIRST
order by (case when status ='Rejected' then -1
else 1
end) desc)
over (partition by id) final_status
from t1
ID STATUS FINAL_STATUS
---------- ---------------- ----------------
1 Waiver Requested Waiver Requested
1 Rejected Waiver Requested
2 Waiver Requested Waiver Requested
2 Waiver Requested Waiver Requested
3 Rejected Rejected
3 Rejected Rejected
4 Waiver Requested Waiver Requested
4 Cancelled Waiver Requested