select n_mon6,to_number(n_mon6||'01') n_permon01 from (
select to_number(to_char(add_months(trunc(v_date_from_d,'yyyy'),level-1),'yyyymm')) n_mon6 from dual connect by level <= 12
) where n_mon6<=v_stat_m_i and (case when v_stat_y_i>=2017 then 201612 else n_mon6 end)=201612--大于等于2017直接取常量
来源:https://www.cnblogs.com/jiangqingfeng/p/7118137.html