17,377
社区成员
发帖
与我相关
我的任务
分享
select a.id1, a.num1, sum(abs(num2)) over(order by id1) num2
from (SELECT id1, num1, case lag(num1, 1, null) over(order by id1) when num1 then 0 else 1 end as num2
from test) a
OVER BY
SELECT T.ID, T.NUM, DENSE_RANK() OVER(ORDER BY T.NUM ASC) FROM TABLE1 T
declare
cursor my_cur is
select t.rowid row_id,t.ID1,t.NUM1
from table1 t
order by 1;
v_count number;
v_j number;
v_pid number;
begin
v_count:=0;
v_j:=1;
v_pid:=0;
for row_t in my_cur loop
if (v_pid=row_t.NUM1) then
begin
update table1 set NUM2=v_j
where rowid=row_t.row_id;
end;
else
begin
v_j:=v_j+1;
update table1 set NUM2=v_j
where rowid=row_t.row_id;
v_pid:=row_t.NUM1;
end;
end if;
v_count:=v_count+1;
if (v_count>=2000) then
commit;
v_count:=0;
end if;
end loop;
commit;
end;
/