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 --然后根据需要分组的字符串排序,最后根据数字排序

原文地址:https://www.cnblogs.com/zwyAndDong/p/14652335.html