1.获取当前时间的前24小时的各小时时间段
select to_date(to_char(sysdate -(rownum - 1) / 24,’yyyy-mm-dd hh24’) || ‘:00:00’,’yyyy-mm-dd hh24:mi:ss’) totalDate
from dual
connect by rownum <= 24 order by totalDate
=========================================================== 2.获取某天的0点到24点的各小时时间段 select to_date(‘2018-04-12’,‘yyyy-mm-dd’) + (rownum - 1) / 24 times from dual connect by level <= 24