按照指定的字符排序,给你个例子: --c2列的数据按'4','1','2'的指定顺序排序 create table t_orderby ( c1 int null, c2 varchar(10) null, c3 varchar(10) null ) go insert into t_orderby select 1,'2','a1' union all select 1,'1','a2' union all select 3,'1','ab' union all select 1,'4','b1' go select * from t_orderby order by charindex(c2,'4,1,2')详见:http://qianzhang.blog.51cto.com/317608/1201724
--c2列的数据按'4','1','2'的指定顺序排序
create table t_orderby
(
c1 int null,
c2 varchar(10) null,
c3 varchar(10) null
)
go
insert into t_orderby
select 1,'2','a1' union all
select 1,'1','a2' union all
select 3,'1','ab' union all
select 1,'4','b1'
go
select * from t_orderby
order by charindex(c2,'4,1,2')详见:http://qianzhang.blog.51cto.com/317608/1201724