这帖中已经回复http://community.csdn.net/Expert/topic/3381/3381231.xml?temp=.9878961

解决方案 »

  1.   

    1.因为null为未知,所以你的select * from table where age >= 10 or age < 10 查不到  age 为null的记录,而select * from table 是查询所有记录,当然就包含null的数据
    2.排序的话,单独的order by age,则null的在前面,非null在后面
      如果你想叫null的在后面的话,order by中使用case when结果控制一下就可以了。
      select * from 表
      order by case when age is null then 1 else 0 end,age
      

  2.   

    --测试:
    create table tb(id int identity(1,1),age int)
    insert  tb values ('1')
    insert  tb values ('5')
    insert  tb values ('2')
    insert  tb values (null)
    insert  tb values (null)select * from tb
    order by case when age is null then 1 else 0 end,age
    drop table tb--运行结果:id          age         
    ----------- ----------- 
    1           1
    3           2
    2           5
    4           NULL
    5           NULL(所影响的行数为 5 行)