抱歉我的错误,我应该提供问题的真实样本,我的 ID 中包含以下字符:
示例代码:
select ID from student order by ID
Expected output from mine but system output
------------------------- -----------------
JAD.1.99.9 JAD.1.99.10
JAD.1.99.10 JAD.1.99.9
和这个ID
is of nvarchar
type.
昨天 https://stackoverflow.com/q/16575406/284240有一个类似的问题,我了解到你可以使用hierarchyid http://msdn.microsoft.com/en-us/library/bb677290.aspx用于版本排序(如果您至少使用 SQL-Server 2008):
SELECT id
FROM student
ORDER BY Cast('/' + Replace(id, '.', '/') + '/' AS HIERARCHYID)
DEMO http://sqlfiddle.com/#!3/e3cb1/1/0
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)