【发布时间】:2020-04-07 21:58:32
【问题描述】:
我有一个类似于以下的 TERADATA 数据集:
'项目:Hercules 问题类型:改进组件:核心 AffectsVersions:2.4.1 优先级:次要时间:15:25:23 04/06/2020'
我想根据key从上面提取标签值。
例如:
with comm as
(
select 'Project: Hercules IssueType: Improvement Components: core AffectsVersions: 2.4.1 Priority: Minor' as text
)
select regexp_substr(comm.text,'[^: ]+',1,4)
from comm where regexp_substr(comm.text,'[^: ]+',1,3) = 'IssueType';
有没有一种方法可以查询而无需更改每个标签的位置参数。 我还发现最后一个字段的日期和时间字段有点棘手。
感谢任何帮助。
谢谢。
【问题讨论】:
-
要返回的确切结果是什么?
-
感谢您的提问。如果上面的内容可以用正则表达式分解成下面的键和值,而不必提供位置参数,那将有所帮助。 ``` Key Value ============== ==================== Project Hercules IssueType Improvement Components core AffectsVersions 2.4.1 Priority Minor时间 15:25:23 04/06/2020 ``