17,086
社区成员
发帖
与我相关
我的任务
分享
select count(1) into v_a from T1 where region_code = 2 group by region_code
v_b := 5000 - v_a;
if v_b < 0
insert into T2 select * from T1 where region_code = 2 and rownum <= 5000
else
v_c := v_c + abs(v_b);
insert into T2 select * from T1 where region_code = 2 and rownum <= v_a
insert into T2 select * from T1 where region_code = 1 and rownum <= v_c