本帖最后由 luofenghen 于 2011-03-16 15:06:27 编辑

解决方案 »

  1.   

    select
     * 
    from
     tb 
    where
     starttime >='2011-03-05' and starttime >='2011-03-10'
    or
     (starttime='2011-03-01' and endTime='2011-03-16' )
      

  2.   


    谢谢楼上的  可能你没读懂  (starttime='2011-03-01' and endTime='2011-03-16' ) 这个时间是记录中的时间  3-05 和3-10 才是查询的时间
      

  3.   

    select * from tb 
    where starttime >='2011-03-05' and starttime >='2011-03-10'
          or convert(varcahr(10),starttime,120)='2011-03-01' or
               convert(varcahr(10),endTime,120)='2011-03-16'
      
      

  4.   

    SELECT * FROM tb WHERE 1=1 AND start_date >= '2011/3/1 0:00:00' and start_date<= '2011/3/10 0:00:00'   or ( end_date between '2011/3/1 0:00:00' and '2011/3/10 0:00:00'   
    目前查询语句为 这样的 但无法得到 start_date ='2011/2/8 0:00:00' 和end_date between '2011/4/1 0:00:00' 的这条数据  
    理论上 这条数据是符合 '2011/3/1 0:00:00' 和 '2011/3/10 0:00:00' 之间的
    请问要如何得到呢?
      

  5.   

    SELECT top 1 * FROM tb WHERE 1=1 AND start_date >= '2011/3/1 0:00:00' and start_date<= '2011/3/10 0:00:00' 
      

  6.   

    SELECT
     top 1 * 
    FROM
     tb 
    WHERE
     1=1 AND start_date >= '2011/3/1 0:00:00' and start_date<= '2011/3/10 0:00:00'
    order by 
      start_date asc
      

  7.   

    SELECT * FROM tb WHERE start_date in (SELECT
     top 100 percent start_date  
    FROM
     tb  
    WHERE
     1=1 AND start_date >= '2011/3/1 0:00:00' and start_date<= '2011/3/10 0:00:00'
    order by  
      start_date asc)
      

  8.   

    都不对  请到我另开贴 看下详细的 需求
    http://topic.csdn.net/u/20110316/15/e87edc01-547f-4ad4-b5e4-e593ea6030ff.html
      

  9.   

    看出来了。区间为:start_date between '2011/3/1' and '2011/3/10' 
    当@start_date <='2011/3/1' 且 @end_date落于区间'2011/3/1' and '2011/3/10' 算符合条件吗?
    当@start_date 落于区间 且@end_date落于区间算符合条件吗?
    当@start_date 落于区间 且@end_date>='2011/3/10'算符合条件吗?
    当@start_date <='2011/3/1' @end_date>='2011/3/10'算符合条件吗?
    请针对上述4种组合给出为真,就有sql语句了