再开帖, 表1  有个 FASJ date字段, 求一个时间段内 从 starttime 到 endtime 之间每隔 指定天数 的记录条数。starttime 和 endtime  都是已知的??   高手来帮忙!!

解决方案 »

  1.   

    狂浪不是写好了?把GROUP BY 去掉就是了
      

  2.   

    試一下這個:
    從1996年1月1日到1999年12月31日之間每隔50天的入職人數。select count(tm.sd),tm.sd
    from employees em,
    (select to_date('19960101000000','yyyymmddhh24miss') + ((level - 1) * 50) sd
    from dual
    connect by level <= ceil((to_date('19991231235959','yyyymmddhh24miss') - to_date('19960101000000','yyyymmddhh24miss')) / 50)
    ) tm
    where EM.HIRE_DATE - tm.sd between 0 and 50
    and em.hire_date between to_date('19960101000000','yyyymmddhh24miss') and to_date('19991231235959','yyyymmddhh24miss')
    group by tm.sd
    order by tm.sd
      

  3.   


    20100101 -- 20100401 每隔10天的时间段 
    select * from 
    (
    select to_date('20100101','yyyymmdd') + ((level - 1) * 10) sd
    from dual
    connect by level <= ceil((to_date('20100401','yyyymmddhh24miss') - to_date('20100101','yyyymmddhh24miss')) / 10)
    )
    order by sd