按日期循環累計字段的更新存儲過程

create or replace procedure updateTotaluser as
date_id_in number;
begin
for i in (select distinct date_id as date_id_in from browser_use_os_f t where t.date_id<=20120220 order by t.date_id) LOOP
begin
update browser_use_os_f t
set t.total_newuser =
(select sum(f.newuser)
from browser_use_os_f f
where f.date_id <= i.date_id_in
and t.country_id = f.country_id
and t.platform_id = f.platform_id
group by f.country_id,f.platform_id) where t.date_id = i.date_id_in;
end;
end LOOP;
end updateTotaluser;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章