数据库表A,字段commit_time存的数据是:20080301112536等。现在我要查询出今天在9:00到10:00,15:00至16:00时间段的数据。请问如何写这样的语句。谢谢!!!

解决方案 »

  1.   

    select * 
      from A 
     where commit_time between to_char(sysdate,'yyyymmdd')||'000900' 
       and to_char(sysdate,'yyyymmdd')||'001000' 
        or commit_time between to_char(sysdate,'yyyymmdd')||'001500' 
       and to_char(sysdate,'yyyymmdd')||'001600' 
      

  2.   

    应该是这样的吧:
    select *  
      from A  
     where commit_time between to_char(sysdate,'yyyymmdd') ¦ ¦'090000'  
       and to_char(sysdate,'yyyymmdd') ¦ ¦'100000'  
        or commit_time between to_char(sysdate,'yyyymmdd') ¦ ¦'150000'  
       and to_char(sysdate,'yyyymmdd') ¦ ¦'160000' 
    ??
      

  3.   

    commit_time like to_char(sysdate,'yyyymmdd')||'09%'
    or 
    commit_time like to_char(sysdate,'yyyymmdd')||'15%'
      

  4.   

    select * from test1
    where (to_date(commit_time,'yyyy-mm-dd hh24:mi:ss')>(trunc(sysdate)+9/24) and
    to_date(commit_time,'yyyy-mm-dd hh24:mi:ss')>(trunc(sysdate)+10/24)) or
    (to_date(commit_time,'yyyy-mm-dd hh24:mi:ss')>(trunc(sysdate)+15/24) and
    to_date(commit_time,'yyyy-mm-dd hh24:mi:ss')>(trunc(sysdate)+16/24));测试是成功的。