oralce 查询一天每隔15分钟一个点 15分钟
select to_char((daybegin + (level - 1) * 15 / 1440), 'hh24:mi') as this15time
from (select (trunc(sysdate, 'dd')) as daybegin from dual)
connect by level <= 96
oracle 每隔5分钟的话,只需要修改 15改成5 level <=改成288
select to_char((daybegin + (level - 1) * 5 / 1440), 'hh24:mi')||':00' as this5time
from (select (trunc(sysdate, 'dd')) as daybegin from dual)
connect by level <=288
查询一个月的数据,每条数据间隔五分钟,笛卡尔积查询
select to_date(days||' '||this5time,'yyyy-mm-dd hh24:mi:ss') datetime from (
SELECT '2020-02-' || TRIM(TO_CHAR(ROWNUM, '00')) AS DAYS FROM DUAL
CONNECT BY ROWNUM <= TO_NUMBER(TO_CHAR(LAST_DAY(TO_DATE('2020-02-01', 'YYYY-MM-DD')), 'DD'))
),(
select to_char((daybegin + (level - 1) * 5 / 1440), 'hh24:mi')||':00' as this5time
from (select (trunc(sysdate, 'dd')) as daybegin from dual)
connect by level <=288
)