sql server 字符串按最后数字排序

SELECT convert(int,case when charindex('#',test)=0 then 0 -- 计算出test字符串后面的数字
else (select substring(test,charindex('#',ResNo)+1,10))
end
) as Num --Num为数字
from table
order by TestNo,Num --然后根据需要分组的字符串排序,最后根据数字排序

posted @ 2021-04-13 11:19  行走在0和1之间  阅读(408)  评论(0编辑  收藏  举报