declare @tb table(smonth varchar(100))
insert into @tb
select '10月' union all
select '11月' union all
select '8月' union all
select '8月' select * from @tb order by smonth
/*
而我想要的结果
smonth                                                                                               
------
8月
8月
10月
11月
*/

解决方案 »

  1.   

    declare @tb table(smonth varchar(100))
    insert into @tb
    select '10月' union all
    select '11月' union all
    select '8月' union all
    select '8月' 
    select * from @tb order by cast(left(smonth,len(smonth)-1)as int) asc
    /*smonth                                                                                               
    ---------------------------------------------------------------------------------------------------- 
    8月
    8月
    10月
    11月*/
      

  2.   


    select * from @tb 
    order by cast(replace(smonth,'月','') as int)smonth
    ---------------
    8月
    8月
    10月
    11月(4 行受影响)
      

  3.   

    declare @tb table(smonth varchar(100))
    insert into @tb
    select '10月' union all
    select '11月' union all
    select '8月' union all
    select '8月' select * from @tb order by cast(replace(smonth ,'月','') as int)/*
    smonth                                                                                               
    ---------------------------------------------------------------------------------------------------- 
    8月
    8月
    10月
    11月(所影响的行数为 4 行)
    */
      

  4.   

    declare @tb table(smonth varchar(100))
    insert into @tb
    select '10月' union all
    select '11月' union all
    select '8月' union all
    select '8月' select *
    from @tb
    order by right('00'+smonth,3)/**
    smonth                                                                                               
    ---------------------------------------------------------------------------------------------------- 
    8月
    8月
    10月
    11月(所影响的行数为 4 行)
    **/
      

  5.   

    declare @tb table(smonth varchar(100))
    insert into @tb
    select '10月' union all
    select '11月' union all
    select '8月' union all
    select '8月' select *
    from @tb
    order by right('00'+smonth,3)/**
    smonth                                                                                               
    ---------------------------------------------------------------------------------------------------- 
    8月
    8月
    10月
    11月(所影响的行数为 4 行)
    **/
      

  6.   


    declare @tb table(smonth varchar(100))
    insert into @tb
    select '10月' union all
    select '11月' union all
    select '8月' union all
    select '8月' select * from @tb order by cast(replace(smonth ,'月','') as int)/*
    smonth                                                                                               
    ---------------------------------------------------------------------------------------------------- 
    8月
    8月
    10月
    11月(所影响的行数为 4 行)
    */