order by isnull(A,B)
????

解决方案 »

  1.   

    order by A,B 这样应该行吧
      

  2.   

    create table tbtest(a int,b int)
    insert tbtest
    select 11,2 union all
    select 11,23 union all
    select 91,24 union all
    select 81,27 union all
    select 71,52 union all
    select 71,12 union all
    select 31,24 union all
    select 41,62 union all
    select 15,82 union all
    select 3,21 union all
    select'' ,22 union all
    select'' ,23 union all
    select '',214 
    --drop table tbtest
    select * from tbtest order by a,b
    (所影响的行数为 13 行)a           b           
    ----------- ----------- 
    0           22
    0           23
    0           214
    3           21
    11          2
    11          23
    15          82
    31          24
    41          62
    71          12
    71          52
    81          27
    91          24(所影响的行数为 13 行)