select * from table order by rtrim(ltrim(col1)) desc

解决方案 »

  1.   

    select * from table where fieldname<>null order by col1 asc 
    union all
    select * from table where fieldname=null我觉得有更好的函数能实现,笨办法:)
      

  2.   


    select * from yourtable where colname=null
    union all
    select * from yourtable where colname<>null order by col asc 
      

  3.   

    select * from table where fieldname is not null order by col1 asc 
    union all
    select * from table where fieldname is null
      

  4.   

    select * from table order by isnull(col1,0)
    select * from table order by isnull(col1,0) desc 
    :)
      

  5.   

    select * 
      from table 
      order by (case 
                     when col1 is null then 1 
                     when rtrim(ltrim(col1))='' then 1
                     else 0
                end ),col1