首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

Oracle 准时间段分组统计

2012-09-27 
Oracle 按时间段分组统计select dt, count(satisfy_degree) as num from T_DEMOi ,(select sysdate - (lev

Oracle 按时间段分组统计

select dt, count(satisfy_degree) as num from T_DEMO  i ,(select sysdate - (level-1) * 2 dtfrom dual connect by level <= 10) dwhere i.satisfy_degree='satisfy_1' andi.insert_time<dt and i.insert_time> d.dt-2group by d.dt  

例子中的sysdate - (level-1) * 2得到的是一个间隔是2天的时间
group by d.dt  也就是两天的时间间隔分组查询

热点排行