首页 > Linux操作系统 > Linux操作系统 > 用oracle构建一年月时间段
select to_char(to_date('200105','yyyymm'),'yyyy')+ b.bb||'00'+a.aa ff
from
(select level aa from dual connect by 1=1 and level <13 ) a,
(select level-1 bb from dual connect by 1=1 and level <=
(to_char(to_date('200402','yyyymm'),'yyyy') - to_char(to_date('200105','yyyymm'),'yyyy')+1) ) b
where to_char(to_date('200105','yyyymm'),'yyyy')+ b.bb||'00'+a.aa >='200105'
and to_char(to_date('200105','yyyymm'),'yyyy')+ b.bb||'00'+a.aa <='200402'
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/134308/viewspace-140578/ ,如需转载,请注明出处,否则将追究法律责任。