action  |     place      | starting_time      | ending_time        |
------  |----------------------------------------------------------|-----------------
技术培训| 技术开发部会议室| 2005-6-26 8:10:00  | 2005-6-26 10:11:00 | 会议很重要
技术培训| 技术开发部会议室| 2005-6-26 11:10:00 | 2005-6-26 12:11:00 | 会议很重要
技术培训| 技术开发部会议室| 2005-6-27 15:10:00 | 2005-6-27 16:11:00 | 会议很重要
技术培训| 技术开发部会议室| 2005-6-27 19:10:00 | 2005-6-27 24:11:00 | 会议很重要...........上面是表,我想得到某一天的记录,并分别分为上午记录、下午记录、晚上记录,时间段如上面

解决方案 »

  1.   

    技术培训| 技术开发部会议室| 2005-6-26 11:10:00 | 2005-6-26 12:11:00 | 会议很重要
    这条属于下午还是上午?是根据starting_time还是根据ending_time和starting_time判断上午,下午,晚上?
      

  2.   

    根据 starting_time字段  里的时间啊?·2
      

  3.   

    是这样吗?
    select 
    (case when starting_time  > trunc(starting_time ) + 8.5/24 and starting_time  < trunc(starting_time ) + 11.5/24 then '上午' 
    when starting_time  > trunc(starting_time ) + 13.5/24 and starting_time  < trunc(OC_ORDER_DATE) + 18.5/24 then '下午' 
    when starting_time  > trunc(starting_time ) + 18.5/24 and starting_time  < trunc(starting_time ) + 24.5/24 then '晚上' 
    else '' end ) "111",a.*
    from agenda1 a
      

  4.   

    select decode(sign(to_date(to_char(starting_time, 'hh24:mi:ss'), 'hh24:mi:ss')
                  -to_date('08:00:00', 'hh24:mi:ss')), 1, '08:00:00', 0,'08:00:00', null) as starting_time,
       decode(sign(to_date(to_char(ending_time, 'hh24:mi:ss'), 'hh24:mi:ss')
              -to_date('08:00:00', 'hh24:mi:ss')), -1, '11:00:00', 0, '11:00:00', null) as ending_time
      
    from agenda1
    这只是上午的共参考