或者是怎么判断两个时间段中的时间是不是整点呢

解决方案 »

  1.   

        select distinct a_time
                 from (select trunc(exittime, 'HH24') c_time
                 from (select exittime
                      from tmp_rawhour t1
                     where t1.rowid = (select max(rowid)
                              from tmp_rawhour t2
                             where t1.exittime = t2.exittime)
                    )
                    ) count_time,
            (select (min_time + (rownum - 1)/24) a_time,
                   rownum rn
              from all_objects,
                   (select min(trunc(exittime, 'HH24')) min_time,
                           max(trunc(exittime, 'HH24')) max_time
                      from tmp_rawhour) loop_time
             where rownum < = (max_time - min_time)*24 + 1) all_time
             where a_time = c_time(+)tmp_rawhour是我的表,exittime是要得到的时间字段
      

  2.   

    with tmp as
    (
    select to_date('2015-05-16 07:20:49','yyyy-mm-dd hh24:mi:ss') max_time,
           to_date('2015-01-21 08:30:00','yyyy-mm-dd hh24:mi:ss') min_time
      from dual
    )
    select trunc(min_time,'hh24')+(1/24)*(level-1) dtime
      from tmp
     connect by level <= (trunc(max_time,'hh24') - trunc(min_time,'hh24')+1/24)*24
    其中max_time和min_time为你指定的时间段.