日期:2014-05-16  浏览次数:20418 次

一个ORACLE间隔时间的查询语句
select distinct(d.dt), sum(d.num) from 
(
  select dt, count(*) as num,i.row_id,i.created_date from testtable  i,
  (select to_date('2011/12/4 18:54:30','yyyy/mm/dd HH24:mi:ss') + (level-1)/86400*5 dt from dual connect by level <= 2000) d   
  where   i.created_date>=dt and i.created_date < d.dt+(5/86400)   
  group by d.dt,i.row_id,i.created_date
  order by dt
) d group by d.dt