如果你要一次连统计结果也算出来,可以试试分析函数,即使使用一般sql,也没那么复杂:
select pros_yymm,sum(seg_atm) from (
select trunc(pros_yymm,'mm',seg_atm)
) group by pros_yymm
然后手工合计
select pros_yymm,sum(seg_atm) from (
select trunc(pros_yymm,'mm',seg_atm)
) group by pros_yymm
然后手工合计
num number;
v_insertSQL varchar2(1000);
begin
select count(*) into num from user_objects where object_name='TMP_SEG_PROS';
if (num > 0) then
v_insertSQL:='drop table tmp_Seg_Pros';
execute immediate v_insertSQL;
end if;
end ;