1、获取当前时间的前24小时的各小时时间段
select to_char(to_date(to_char(sysdate - (rownum - 1) / 24,'yyyy-mm-dd hh24') || ':00:00','yyyy-mm-dd hh24:mi:ss'),'yyyy-mm-dd hh24:mi:ss') totaldate from dual connect by rownum <= 24 order by totaldate desc
2、获取某天的0点到24点的各小时时间段
select TO_CHAR(to_date('2019-01-28','yyyy-mm-dd') + (rownum - 1) / 24,'yyyy-mm-dd hh24:mi:ss') TIMES from DUAL connect by level <= 24
3、获取0点到当前时间的小时段
select TO_CHAR(to_date('2019-01-28','yyyy-mm-dd') + (rownum - 1) / 24,'yyyy-mm-dd hh24:mi:ss') TIMES from DUAL connect by level <= to_char(sysdate + 1 / 24,'hh24')