select * from orders where( OrderDate between '2007-1-1' and '2007-6-30') or (OrderDate between '2007-7-1' and '2007-7-31') or (OrderDate between '2007-8-1' and '2007-8-31')

解决方案 »

  1.   

    或者
    select * from orders where  (DATEPART(year,OrderDate)=2007 and ((DATEPART(month,OrderDate) between 1 and 6) or DATEPART(month,OrderDate)=7 or DATEPART(month,OrderDate) = 8 )) 
      

  2.   


    select right(Convert(varchar(4),year(日期字段)),2)+Convert(varchar(2),month(日期字段))
      

  3.   

    可以作为参数,然后进来判断 有多少个,自己组合sql语句啊
      

  4.   

    qgmzhfj 新手,望指点!!---请不要再参与了,谢谢你的热情@!!!
      

  5.   

    这个事情干的比较多
    建议加一张表,这表的结构就是你的条件以前经常给用户发奖,发奖就有众多各类条件============================
    表table_aID  sTime
    1    2007-03-01
    2    2007-10-01表table_bbegintime  endtime
    2007-06-01 2007-07-01
    2007-08-01 2007-09-30然后么自己看着办咯select * from table_a as t1,table_b as t2 where t1.stime < t2.endtime and t1.stime>t2.begintime呵呵,这样就找到了你想要的因为考虑到你的条件不确定,所以,这样的方式扩展性很好,随便条件你都可以