opH*_*AME 5 sql sorting oracle ip-address
我在varchar2列中有以下内容:
10.1.2.3
10.2.3.4
8.3.4.1
8.3.2.1
4.2.1.3
4.3.2.1
9.3.1.2
Run Code Online (Sandbox Code Playgroud)
当我查询数据库时,我需要一个有序的结果:
4....
8....
9....
10...
Run Code Online (Sandbox Code Playgroud)
NLS_SORT参数设置为德语,简单的" order by COLUMN DESC/ASC" 不像excepted 一样工作.它回来了
10.....
8......
9......
Run Code Online (Sandbox Code Playgroud)
有什么建议?
假设它是一个IP地址
SELECT col
FROM table
ORDER BY
(regexp_substr(col, '[^.]+', 1, 1) * 256 * 256 * 256 ) + (regexp_substr(col, '[^.]+', 1, 2) * 256 * 256) + (regexp_substr(col, '[^.]+', 1, 3) * 256 )+ regexp_substr(col, '[^.]+', 1, 4)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2393 次 |
| 最近记录: |