Oracle数字字符串排序
上一篇 /
下一篇 2017-02-07 10:49:41
/ 个人分类:其他
Oracle数据库中假设有某个值id数字
字符串,如1,2,3,4,5,6,7,8,9,10
select id from tablename order by id desc
结果排序9是最大,
9
8
7
6
5
4
3
2
10
1
那么如果想要按照10,9,8...3,2,1这种方式打印,可以按照如下方式:
to_number(regexp_substr(id,'[0-9]*[0-9]',1)) desc
顺便
记录一下:获取一个表中最大id,需要用同表嵌套查询
select id into SNO from ( select id from tablename where id is not null order by to_number(regexp_substr(id,'[0-9]*[0-9]',1)) desc) where rownum <=1
相关阅读:
- 如何定位Oracle数据库被锁阻塞会话的根源 (zaza9084, 2016-12-29)
- ORACLE从共享池删除指定SQL的执行计划 (zaza9084, 2017-1-06)
- Oracle数据库基础知识(华为内部培训资料) (zaza9084, 2017-1-05)
- navicat premium 连接oracle数据库 (123_456, 2017-1-12)
- Linux服务器安装Oracle服务端总结 (zaza9084, 2017-1-16)
- Oracle认证正确的教与学方法论 (zaza9084, 2017-1-16)
- Oracle运维中的那些事儿 (zaza9084, 2017-1-19)
- 使用Oracle构建企业私有云 (zaza9084, 2017-1-23)
- Oracle启动脚本及开机自启动设置 (zaza9084, 2017-2-07)
- Oracle BEQ方式连接配置 (zaza9084, 2017-2-08)
收藏
举报
TAG:
Oracle
字符串