row_number()
が必要だと思います :
select t.*,
(row_number() over (partition by c1, c2, c3, c4, c5 order by c6) - 1
) as "Count"
from t;
merge
を使用できます これをupdate
に入れます 声明。または、本当にupdate
が必要な場合 :
update t
set count = (select count(*)
from t t2
where t2.col1 = t.col1 and t2.col2 = t.col2 and t2.col3 = t.col3 and
t2.col4 = t.col4 and t.col5 = t2.col5 and
t2.col6 < t.col6
);