Hvorfor ikke bare bruge substr()
?
select t.*, to_number(substr(element_id, 3, 2)) as my_seq
from t;
En anden tilgang er at bruge dense_rank()
:
select t.*,
dense_rank() over (partition by u_a_id order by substr(element_id, 1, 4)) as my_seq
from t;
Du kan bruge merge
hvis du rent faktisk vil opdatere dataene:
merge into t using
(select t.*,
dense_rank() over (partition by u_a_id order by substr(element_id, 1, 4)) as new_my_seq
from t
) s
on s.u_a_id = t.u_a_id and s.element_id = st.element_id
when matched then update
set t.my_seq = s.new_my_seq;