sql - Oracle regexp_substr 提取数据 - 2
问题描述
旧问题 ID = 62489141
我添加了另一个输入文本。
我正在尝试从字符串中提取下载和上传速度数,无法实现,请帮助。
下面的字符串存在于表的一列中
输入字符串:
My ADSL 2M(200) Volume 14Mbps/2M speed threshold 0M
我需要出的SQL应该是
download_speed upload_spped
14 2
如果没有其他数字,则以前建议的 SQL 提取数据正确提供。
解决方案
您可以regexp_substr
按如下方式使用:
with d (str) as
(select 'My ADSL 2M(200) Volume 14Mbps/2M speed threshold 0M'
from dual)
-- your query starts from here.
select regexp_substr(spd, '[0-9]+',1,1) as download_speed,
regexp_substr(spd, '[0-9]+',1,2) as upload_speed
from
(select regexp_substr(str, '[0-9]+M[a-z|A-Z]+/[0-9]+[a-z|A-Z]+') as spd
from d)
推荐阅读
- c - 在 C 中动态填充静态数组时出错
- javascript - 加载更多项目后自动向上滚动(无限滚动)
- sql - 更新 Google BigQuery 表中的无效时间戳
- python - 如何使用 Scrapy 将对象从一个规则发送到另一个规则
- c# - varbinary 的特定大小与 blob 大小
- python - 从 Azure DevOps Python Artifacts 源安装 pip 不起作用
- azure - 适用于 Hyper-V 的 Azure VM 迁移设备
- postcss - CSSNext postcss-custom-media - 无法使用“importFrom”选项从文件中导入媒体
- php - 在 Eclipse 上安装 PHP 环境时遇到问题
- excel - 带有 2 个公式的条件格式