字母数字数据排序 [英] sorting of alphanumeric data

查看:94
本文介绍了字母数字数据排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从表名顺序中按数字选择数字

它显示如下

1

10

11

14

14A

14AA
19

2

20

21
相反,它应显示如下

1

2

10

11

14

14A

14AA
19

20

Select Number from tableName order by Number

it displays like below

1

10

11

14

14A

14AA
19

2

20

21
Instead it should display like below

1

2

10

11

14

14A

14AA
19

20

推荐答案

http://stackoverflow.com/questions/8148778/sorting-alphanumeric-data [ ^ ]
How to Sort Alphanumeric Data in SQL[^]

http://stackoverflow.com/questions/8148778/sorting-alphanumeric-data[^]


您好,

请参阅以下查询.它将为您提供所需的输出.

Hi,

See the below query. It will give you desired output.

<pre lang="sql">select SrNo from Table_1
order by case
when SrNo like '%[0-9]%' then 1
else 0
end,
SrNo



这里的SrNo是您的表列名称.

谢谢,
Viprat



Here SrNo is your table column name.

Thanks,
Viprat




Hi,

Select Row_Number() Over (Order by
Case When IsNumeric(User_Name) = 1 then Right(Replicate(''0'',21) + User_Name, 20)
                          When IsNumeric(User_Name) = 0 then Left(User_Name + Replicate('''',21), 20)
                        Else User_Name
               END) As RowNumber,User_Name
From Users


这篇关于字母数字数据排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆