日期:2014-05-16 浏览次数:20515 次
create table T_DEMO ( SATISVACTION_ID VARCHAR2(10) not null, TEL_NUM VARCHAR2(20) not null, SATISFY_DEGREE VARCHAR2(15), INSERT_TIME DATE, STAFF_ID VARCHAR2(10) )
---level 是一个伪例 select level from dual connect by level <=10 ---结果:1 2 3 4 5 6 7 8 9 10
select sysdate -1 from dual ----结果减一天,也就24小时 select sysdate-(1/2) from dual -----结果减去半天,也就12小时 select sysdate-(1/24) from dual -----结果减去1 小时 select sysdate-((1/24)/12) from dual ----结果减去5分钟 select sydate-(level-1) from dual connect by level<=10 ---结果是10间隔1天的时间
select dt, count(satisfy_degree) as num from T_DEMO i , (select sysdate - (level-1) * 2 dt from dual connect by level <= 10) d where i.satisfy_degree='satisfy_1' and i.insert_time<dt and i.insert_time> d.dt-2 group by d.dt