首页 > 其他 > 详细

截取字符串中前8个数字

时间:2019-01-11 14:37:14      阅读:206      评论:0      收藏:0      [点我收藏+]

先替换非数字的为空,再截取

with tmp_a as (
  select ‘2018-10-15 12:30:59‘ update_time from dual union all --结果是 20181015
  select ‘2017/10/16 12:30:59‘ update_time from dual union all --结果是 20171016
  select ‘20151015 12:30:59‘   update_time from dual union all --结果是 20151015
  select null                  update_time from dual union all --结果是 空
  select ‘201510‘              update_time from dual union all --结果是 201510
  select ‘20131015123059‘      update_time from dual           --结果是 20131015
)
select substr(regexp_replace(update_time,‘[^0-9]‘),1,8) 截取前8个数字 from tmp_a

截取字符串中前8个数字

原文:https://www.cnblogs.com/jiangqingfeng/p/10254952.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!