表中有如下記錄
100B
100-B
100A
100-AORDER BY時.想按如下方式排列
100-A
100-B
100A
100B如何寫,不要急關回簽,有興趣的可以試一下."-"和"-"的排序很很怪.
100B
100-B
100A
100-AORDER BY時.想按如下方式排列
100-A
100-B
100A
100B如何寫,不要急關回簽,有興趣的可以試一下."-"和"-"的排序很很怪.
调试欢乐多
where charindex('-',orderFieldName)>0
order by orderFieldName
union all
select * from tablename
where charindex('-',orderFieldName)<0
order by orderFieldName
select *
from (select '100B' as aaa
union select '100-B'
union select '100A'
union select '100-A') a
order by replace(aaa, '-', char(ascii('A') - 1))
select *
from (select '100B' as aaa
union select '100-B'
union select '100A'
union select '100-A') a
order by replace(aaa, '-', char(ascii('A') - 1))
/*
aaa
100-A
100-B
100A
100B
*/