DECLARE
CURSOR c_t2 is select * from t2;
BEGIN
FOR i in c_t2 LOOP
insert into t3(total,orgid,trade)
select total,orgid,trade
from (select * from t1
where trade= i.trade
order by total)
where rownum <=i.num;
END LOOP;
END;
CURSOR c_t2 is select * from t2;
BEGIN
FOR i in c_t2 LOOP
insert into t3(total,orgid,trade)
select total,orgid,trade
from (select * from t1
where trade= i.trade
order by total)
where rownum <=i.num;
END LOOP;
END;
取出多少行需要用rownum,这个东西是不能分组的~