select * from 表
order by  case when code is not null then code else 'zzzzzzz' end

解决方案 »

  1.   

    try:
    select * from table where code is not null order by code union
    select * from table where code is null order by id
      

  2.   

    select * from 表 order by isnull(code,'zzzzzzzz'),id
      

  3.   

    select * from 表 order by isnull(code,'zzzzzzzzzzz'),id
      

  4.   

    order by case when 1=isnumeric(code) then '1'  else '2' end, 
    case when 1=isnumeric(left(code,1)) then '1'  else '2' end, 
    code
      

  5.   

    select * from 表 order by isnull(code,'zzzzzzzz'),id

    select * from 表 order by isnull(code,'zzzzzzzzzzz'),id
    区别 在哪里?
    是什么意思啊?不好意思,菜鸟一个!!
      

  6.   

    怕你数据中会出现多于'zzzzzzzz' 的数据,就不能保证'zzzzzzzz' 排在最后 ,所以后者取了你数据表中出现的最大自符数目,保证其总能排在最后。