方法而已,不要死抠代码是否有错:create table myorder(style primary key,顺序号)
select .....
  from 查询结果 as a left join myorder as b on a.style=b.style
  order by b.顺序号

解决方案 »

  1.   

    关键就是:你自已指出排序的顺序,SQL Server默认排序不用。
      

  2.   

    当然啦,如果只有三个值而且是“死”的,也许:select ... from 查询结果 order by case style when 200 then 50 else style end可行。
      

  3.   

    select *
    from T
    order by (case when style = 200 then 1
                  when style = 100 then 2
                  when style = 300 then 3
             end)
      

  4.   

    select * from 你的表 order by charindex(','+cast(style as varchar(10))+',',',200,100,300,'),其他字段
      

  5.   

    select 1 as aid,* from T where style =200
    union
    select 2 as aid,* from T where style =100
    union
    select 3 as aid,* from T where style =300
    order by aid
      

  6.   

    不知道明白你的意思没有
    col          style
    3            100
    5            200
    9            100
    1            300
    2            200
    8            300
    排序后
    2             200
    5             200
    3             100
    9             100
    1             300
    8             300
    select col,style from table group by style,col 
           order by 
            (case when style = 200 then 1
                  when style = 100 then 2
                  when style = 300 then 3
            end),col
      

  7.   

    select * from 你的表 order by charindex(','+cast(style as varchar(10))+',',',200,100,300,'),其他字段
      

  8.   

    select * from 表 order by (case when style = 200 then 1
                                    when style = 100 then 2
                                    when style = 300 then 3
                               end)
      

  9.   

    只能是这两种之一了。
    1:
    select * from 你的表 order by charindex(','+cast(style as varchar(10))+',',',200,100,300,'),其他字段
    2:
    select * from 表 order by (case when style = 200 then 1
                                    when style = 100 then 2
                                    when style = 300 then 3
                               end),其他字段
      

  10.   

    select * from table order by (case when style =200 then 1
                                       when style =100 then 2
                                       when style =300 then 3
                                  end),主字段
      

  11.   

    1.
    select * from table where style = 200 order by field1, field2
    union
    select * from table where style <> 200 order by field1, field22.
    select field1, field2, ...fieldn,
           GroupId =
           CASE style
             WHEN 200 THEN 0
             ELSE 1
           END
    order by GroupId, field1, field2如果不认 GroupId ,加上单引号试试。没有SQLSERVER,没有试验。第二种方法主要是注意CASE的使用
    select field1, field2, ...fieldn,
           GroupId =
           CASE 
             WHEN style=200 THEN 0
             WHEN style=100 THEN 1
             WHEN style=300 THEN 2
           END
    order by GroupId, field1, field2orselect field1, field2, ...fieldn,
           CASE style
             WHEN 200 THEN 0
             WHEN 100 THEN 1
             WHEN 300 THEN 2
           END
    order by style, field1, field2没有SQL数据库,都是想当然的,自己试试吧
      

  12.   

    select * from 表 order by (case when style = 200 then 1
                                    when style = 100 then 2
                                    when style = 300 then 3
                               end),主字段
      

  13.   

    select * from 你的表 order by charindex(','+cast(style as varchar(10))+',',',200,100,300,'),其他字段或:select * from 表 order by (case when style = 200 then 1
                                    when style = 100 then 2
                                    when style = 300 then 3
                               end),其他字段