create procedure pro
as
begin
update dm_wz_his a set f_zc_day03=(select f_sl from (select * from his where f_wzyy is not null order by f_rq desc) b where a.f_cdxs=b.f_cdxs and rownum<4);
end;
/
as
begin
update dm_wz_his a set f_zc_day03=(select f_sl from (select * from his where f_wzyy is not null order by f_rq desc) b where a.f_cdxs=b.f_cdxs and rownum<4);
end;
/
select count(b.f_sl) as f_pc,b.f_cdxs
from (select * from his where f_wzyy is not null order by f_rq desc) b,his
where b.f_cdxs=his.f_cdxs and rownum<=10
group by b.f_cdxs;
pc_rec pc_cur% rowtype;
begin
for pc_rec in pc_cur loop
update dm_wz_his set f_wz_pc10=pc_rec.f_pc
where dm_wz_his.f_cdxs=pc_rec.f_cdxs and rownum<=10;
end loop;
end;
但是这样写的话有错误:它相当于count(*)了没有起到rownum的作用啊!
_WZ_PC10
--------
12
110
38
3
282
1
1
1
1
2
2_WZ_PC10
--------
1
1
5
5
22
2
5
1
7
1
4_WZ_PC10
--------
3
1
2
5
2
20
3
275
1
5
33