日期:2014-05-17  浏览次数:20441 次

这个怎么排序啊?
有这么一列
a
1-1-18-1
1-1-2-1

1-1-2-1应该排在1-1-18-1前面

------解决方案--------------------

;with tb(col) as
(
select '1-1-18-1'
union all select '1-1-2-1'
)
select col
from 
(
select COL,rn=cast(REPLACE(col,'-','') as int) from tb
)t
order by rn

/*
col
----------------------
1-1-2-1
1-1-18-1
*/

------解决方案--------------------
如果想2的在前面, 就截取那 一段 转换成数字  在排序