原文链接:http://blog.csdn.net/ld422586546/article/details/9626921/
----------------------------------------------------------------------
获取一段时间内所有的小时
SELECT to_date('2013-07-01 12','yyyy-mm-dd hh24') + (ROWNUM - 1) / 24 sdate FROM dual
CONNECT BY ROWNUM <= (to_date('2013-07-02 22','yyyy-mm-dd hh24') - to_date('2013-07-01 12','yyyy-mm-dd hh24')) * 24 + 1;
获取一段时间内所有的天
SELECT to_date('2013-07-01','yyyy-mm-dd') + ROWNUM - 1 sdate FROM dual
CONNECT BY ROWNUM <= to_date('2013-07-05','yyyy-mm-dd') - to_date('2013-07-01','yyyy-mm-dd') + 1;
获取一段时间内所有的月
SELECT to_char(add_months(to_date('2013-01','yyyy-mm'),ROWNUM - 1),'yyyy-mm') day_id FROM dual CONNECT BY ROWNUM <= months_between(to_date('2013-07',to_date('2013-01','yyyy-mm')) + 1;
原文链接:https://www.f2er.com/oracle/208841.html