Vous pouvez "classer" différents statuts en fonction de votre logique, puis choisir le dernier statut parmi eux. Vous pouvez utiliser la logique similaire à celle ci-dessous, qui repousse tous les "rejets".
Assurez-vous d'inclure tous les autres statuts possibles si vous vous souciez de la commande pour les autres.
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