select distinct a.str_deductbill_no 
from [sellrebate].dbo.t_deduct_account_detail a 
where (a.str_bill_no not  between  '200812260000' and '200903259999')
and str_deductbill_no='200901070089' 
order by str_deductbill_no 后面这个加上括号试一下.

解决方案 »

  1.   

    同意1樓的方法,或者
    select distinct a.str_deductbill_no 
    from [sellrebate].dbo.t_deduct_account_detail a 
    where  str_deductbill_no='200901070089' and
    a.str_bill_no not  between  '200812260000' and '200903259999'
    order by str_deductbill_no 
      

  2.   

    是不是只有一条记录'200901070089' ?select distinct a.str_deductbill_no 
    from [sellrebate].dbo.t_deduct_account_detail a where a.str_bill_no not  between  '200812260000' and '200903259999' and str_deductbill_no='200901070089' 
      

  3.   

    加()没用的
    再仔细说明一下,在[sellrebate].dbo.t_deduct_account_detail 表中有一个记录字段str_bill_no='200812250375'  
    他的 str_deductbill_no='200901070089' 
    大家看我的语句select distinct a.str_deductbill_no 
    from [sellrebate].dbo.t_deduct_account_detail a where a.str_bill_no   between  '200812260000' and '200903259999' and str_deductbill_no='200901070089' 
    查询时应该不会出现str_deductbill_no='200901070089' 
    但是现在就是有这个记录出现,所以不知道原因?谢谢大家回复!
      

  4.   

    如果语句改为
    select distinct a.str_deductbill_no 
    from [sellrebate].dbo.t_deduct_account_detail a where a.str_bill_no not between  '200812260000' and '200903259999' and str_deductbill_no='200901070089' 结果也一样
      

  5.   

    select a.str_deductbill_no, a.str_bill_no
      from [sellrebate].dbo.t_deduct_account_detail a
      where str_deductbill_no='200901070089' 检查一下有几条记录