日期:2014-05-16 浏览次数:20805 次
select distinct t2.dt,
max(t1.price) over(partition by t2.dt) high,
min(t1.price) over(partition by t2.dt) low,
trunc(avg(t1.price) over(partition by t2.dt), 2) bal,
min(t1.price) keep(dense_rank first order by t1.datatime) over(partition by t2.dt) open,
max(t1.price) keep(dense_rank last order by t1.datatime) over(partition by t2.dt) close,
max(t1.db) keep(dense_rank last order by t1.datatime) over(partition by t2.dt) db2
from t1 ,(
select to_date('2012-06-11 13:00:00', 'yyyy-mm-dd hh24:mi:ss') -
(level - 1) * 3 / 1440 dt
from dual
connect by level <= 21
) t2 where t1.datatime>=t2.dt-3/1440 and t1.datatime<t2.dt