1.
select * from table where style = 200 order by field1, field2
union
select * from table where style <> 200 order by field1, field2
2.
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, field2
or
select field1, field2, ...fieldn,
CASE style
WHEN 200 THEN 0
WHEN 100 THEN 1
WHEN 300 THEN 2
END
order by style, field1, field2
只能是这两种之一了。
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),其他字段
不知道明白你的意思没有
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