case when 用法

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直接取常量

 

posted @ 2017-07-04 19:13  江清风  阅读(1583)  评论(0编辑  收藏  举报