use pubscreate view test as 
select stor_id,ord_num,qty,payterms,first1=0,second1=0,third1=NULL
FROM SALES
select * from test
where stor_id='6380'
and not ((first1=0 and third1=100) or (first1=0 and second1=1 and third1=100) or (first1=0 and third1>0))
这个写法是以前公司一位前辈写的,现在被提为BUG.
请高手分析下问题在哪,应该有两条数据才对,可加没加NOT,查出来都没数据。
谢谢

解决方案 »

  1.   

    那个null是不能与int数据比较的。。third1=100就会与100进行比较。这样比较不对的。。而系统语法编译是可行的,因此系统是不会报错的。。third1=null 条件判断只能third1 is null 或者third1 is not null这样语法。。才会有数据。。
      

  2.   

    third1=NULL 
    这种在sybase,oracle,mysql中是可行的,sqlserver里必须用 is (not) null
    记住在sqlserver里 =null 只有赋值时才有效。