Sql Oracle 10g-使用字母对数字进行排序

Sql Oracle 10g-使用字母对数字进行排序,sql,oracle,sorting,oracle10g,Sql,Oracle,Sorting,Oracle10g,我需要对以下值列表进行排序,包括点: 1. 10. 2f. 2c. 2a. 我需要按以下顺序对它们进行排序: 1. 2a. 2c. 2f. 10. 我在SQL Developer上使用以下代码对列表进行排序: with testdata as ( select column_value from table (sys.odcivarchar2list ('1. ' ,'10. ' ,'2f. ' ,'2b. ' ,'2a. ')) ) select colum

我需要对以下值列表进行排序,包括点:

1. 10. 2f. 2c. 2a. 我需要按以下顺序对它们进行排序:

1. 2a. 2c. 2f. 10. 我在SQL Developer上使用以下代码对列表进行排序:

with testdata as ( select column_value from table (sys.odcivarchar2list ('1. ' ,'10. ' ,'2f. ' ,'2b. ' ,'2a. ')) ) select column_value from testdata order by case when replace(translate(trim(column_value),'0123456789','0'),'0','') is null then to_number(column_value) end ,column_value / 但我没有得到我想要的结果:

1. 10. 2a. 2c. 2f. 提前感谢您的帮助。

您可以使用regexp\u substr先按字符串中的数字排序,然后按剩余的非数字字符排序。这假定字符串始终有数字后跟非数字字符

select column_value
from testdata
order by cast(regexp_substr(column_value,'[0-9]+') as int), 
regexp_substr(column_value,'[^0-9]+')
可以使用regexp_substr先按字符串中的数字排序,然后按剩余的非数字字符排序。这假定字符串始终有数字后跟非数字字符

select column_value
from testdata
order by cast(regexp_substr(column_value,'[0-9]+') as int), 
regexp_substr(column_value,'[^0-9]+')
一个上下文一个上下文