SQL语句按in排序

根究需求 需要在in里面排序 

sqlserver写法: 

select h.pk_timeitem,h.timeitemcode,h.timeitemname,h.timeitemname2,b.pk_timeitemcopy from tbm_timeitem h 

left join tbm_timeitemcopy b  on b.pk_timeitem = h.pk_timeitem where b.enablestate='2' and h.enablestate='2'  
and h.itemtype='0' and b.pk_org ='pk_org'
 and  timeitemcode in('105','NP','119','PSLHK','115')

ORDER BY CHARINDEX(','+timeitemcode+',',',105,NP,119,PSLHK,115,')"

原文地址:https://www.cnblogs.com/alexhere/p/9948440.html