gpt4 book ai didi

sql - 从字符串 SQL Netezza 中提取序列号

转载 作者:行者123 更新时间:2023-12-04 08:47:29 25 4
gpt4 key购买 nike

请我需要一个可以从 Logmsg 中提取序列号的查询,困难的是它不遵循特定模式,没有固定的分隔符,并且序列长度总是不一样

|LogMsg                                                                                    |
|------------------------------------------------------------------------------------------|
|Customer Receive CPE Indoor. serial 21530369847SKA011094, user:ahmed.o.haraz |
|Customer Receive CPE Indoor as change. serial :21530369847SK9078291, user:Abdullah.M160275|
|Customer Receive CPE Indoor as change. serial :T5D7S18802909825, user:ahmed.o.haraz |
|Customer Receive CPE Indoor as change. serial :T5D7S18802909830, user:ahmed.o.haraz |
|Customer Receive CPE Indoor. serial ZTERRTHJ9303771, user:Mohamed.E176246 |
|Customer Returned CPE. serial :21530369847SKA011094, user:ahmed.o.haraz |
结果将如下所示:
|Serial              |
|--------------------|
|21530369847SKA011094|
|21530369847SK9078291|
|T5D7S18802909825 |
|T5D7S18802909830 |
|ZTERRTHJ9303771 |
|21530369847SKA011094|

最佳答案

一种方法是 regexp_replace() ,但您对以下内容有不同的格式 serial .所以:

select replace(replace(regexp_extract(logmsg, 'serial [^,]+'), 'serial ', ''), ':', '')

关于sql - 从字符串 SQL Netezza 中提取序列号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64241397/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com