这样的order by 应当怎样写解决方案

这样的order by 应当怎样写解决方案

这样的order by 应当怎样写

某table有一varchar字段mark_code,数据格式如下#1,#2,#3,……,#10,……,请问怎样写sql的order   by   使select的结果如“#1,#2,#3,……,#10,……”排列?



ORDER BY SUBSTRING(mark_code,2)+0




order by replace(mark_code, ‘# ‘,1)




order by cast(substring(name,2) as unsigned) asc




declare @myTable table(a varchar(10))

insert into @myTable

select ‘#1 ‘ union all

select ‘#2 ‘ union all

select ‘#3 ‘ union all

select ‘#4 ‘ union all

select ‘#5 ‘ union all

select ‘#6 ‘ union all

select ‘#7 ‘ union all

select ‘#9 ‘ union all

select ‘#10 ‘ union all

select ‘#11 ‘

select * from @myTable order by convert(int,substring(a,2,len(a)))

这样的order by 应当怎样写解决方案

相关文章:

你感兴趣的文章:

标签云: