SQLSERVER指定顺序排序代码为:
CHARINDEX(RTRIM(CAST(列名 as NCHAR)),您指定排序的类型或字符串)
如下:
select * from 表名 where 1=1
order by CHARINDEX(RTRIM(CAST(列名 as NCHAR)),'2,3,1')
结果是:2,3,1
select case when f.id=6 then 5 else f.id end as zb_tbdw,d.* from HrmSubCompany f left join
(select a.zb_nf,a.zb_yf+1 yf ,a.zb_tbdw as zb_tbdw1 ,b.mx_rq
,b.mx_jgzc,b.mx_zbld from dbo.formtable_main_66 a inner join
dbo.formtable_main_66_dt1 b on a.id=b.mainid where a.zb_nf=${p1}
and a.zb_yf=${p2}-1 and b.mx_rq=${p3} )
d on f.id=d.zb_tbdw1 where f.id in (6,55,56,78,57,58,59,71,72,70,79,60,61,76,66,67,68,75,69,62,65,63,64,73,74)
order by CHARINDEX(RTRIM(CAST(id as NCHAR)),'6,55,56,78,57,58,59,71,72,70,79,60,61,76,66,67,68,75,69,62,65,63,64,73,74')
注:https://www.jianshu.com/p/01a9eed5c31e