日期:2014-05-17 浏览次数:20906 次
with
t as (select 3 mon,2 sum from dual union all
select 4 mon,3 sum from dual union all
select 5 mon,12 sum from dual union all
select 10 mon,22 sum from dual)
select t2.mon,nvl(sum,0)
from (select start_mon+level-1 mon
from (select LEAST(min(mon),1)start_mon,GREATEST(max(mon),12)end_mon from t) t1
connect by level<=end_mon-start_mon+1)t2,t
where t2.mon=t.mon(+)
order by mon;
--替换t表