where datepart(yy,time)=2001 
    and datepart(mm,time)=11
    and datepart(dd,time) > 0  and datepart(dd,time) < 30
    and datepart(hh,time) >0 and datepart(hh,time) < 24

解决方案 »

  1.   

    如果你的天真的是任意的,比如11月,2,5,6,10,的10,12,13,22这样的数据,就只有用in 了,不过在用in之前可以先取出它的一个子集后再用in,比如如果都是11月的
    可以先
    (select * from table where time between 2001年11月 and 2001年12月  (具体自己写)
    然后从a里取出剩下满足条件的记录
      

  2.   

    to flowerofwind
    只是为了用户录入的方便,用户可以在界面上随意点取任意天,任意时
    问题的关键时条件中应用了datepart极大的影响了查询速度
      

  3.   

    to xzou:
      在sybase中好像不能使用select field from select field from table这样的语句
      

  4.   

    不会把,sql server可以,sybase差不多就可以呀