码迷,mamicode.com
首页 > 其他好文 > 详细

截取字符串中前8个数字

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

标签:ace   nio   结果   time   dual   with   sel   bsp   substr   

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

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个数字

标签:ace   nio   结果   time   dual   with   sel   bsp   substr   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!