如何在oracle的字母数字列中使用order by [英] how to use order by in alphanumeric column in oracle
本文介绍了如何在oracle的字母数字列中使用order by的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的表格的第一列中,我的值如下所示
In my table one of column i have a value like below
Y-1
Y-2
Y-3
Y-4
Y-5
Y-6
Y-7
Y-8
Y-9
Y-10
Y-11
Y-12
Y-13
Y-14
当我按此列排序时,如果该行的值最高为Y-9,则工作正常,否则我的结果将是错误的,如下所示.
when i am order by this column its working fine if the row has value up to Y-9 other wise my result is wrong like below.
Y-1
Y-10
Y-11
Y-12
Y-13
Y-14
Y-2
Y-3
Y-4
Y-5
Y-6
Y-7
Y-8
Y-9
但是我想要下面的输出
Y-1
Y-2
Y-3
Y-4
Y-5
Y-6
Y-7
Y-8
Y-9
Y-10
Y-11
Y-12
Y-13
Y-14
如何达到上述结果.我正在使用oracle数据库.任何帮助将不胜感激!!!!
How to acheive the above result.i am using oracle database.Any help will be greatly appreciated!!!!!
推荐答案
您可以通过操作列内容并将其转换为数字来使用订单,例如:
You can use an order by manipulatinng the column content and cast to number eg:
order by substr(col1, 1,2), TO_NUMBER(sustr(col1, 3,10))
这篇关于如何在oracle的字母数字列中使用order by的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文