Perché non usare semplicemente substr()
?
select t.*, to_number(substr(element_id, 3, 2)) as my_seq
from t;
Un secondo approccio consiste nell'usare dense_rank()
:
select t.*,
dense_rank() over (partition by u_a_id order by substr(element_id, 1, 4)) as my_seq
from t;
Puoi usare merge
se vuoi effettivamente aggiornare i dati:
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;