oracle 时间区间内求平均值

获取时间区间内,每两小时的平均值

select
cast(avg(case when TE4777_1=9999 then 0 else TE4777_1 end) as decimal(6,2)) as TE_2102 ,
to_date('2021-09-21 20:21:00','yyyy-mm-dd hh24:mi:ss') +(TRUNC(((timestamp-to_date('2021-09-21 20:21:00','yyyy-mm-dd hh24:mi:ss'))*24*60)/15 ,0)*120-1) /24/60 tiemstamp
from HEARTH_TC_05M_HIST
where timestamp > to_date('2021-09-21 20:21:00','yyyy-mm-dd hh24:mi:ss')
and timestamp <= to_date('2021-09-21 23:00:00','yyyy-mm-dd hh24:mi:ss')

group by TRUNC(((timestamp-to_date('2021-09-21 20:21:00','yyyy-mm-dd hh24:mi:ss'))*24*60)/15 ,0)*120

order by TRUNC(((timestamp-to_date('2021-09-21 20:21:00','yyyy-mm-dd hh24:mi:ss'))*24*60)/15 ,0)*120

 

 

 

 

获取随机值

((0.1 - 0.01) * DBMS_RANDOM.VALUE) 

posted @ 2021-11-04 22:36  若梦浮华  阅读(834)  评论(0编辑  收藏  举报