我正在寻找将一列的值拆分为另一列的查询,下面是当前列的示例,其中包含值以及期望的新列。
Asset
ora-abacogp.de.hsbc, 1626, ABACOGP
frlooraprda1.systems.uk.hsbc, 60002, ABM00
fr00parp0845ora.hibm.sub.fr.hsbc, 1521, ACC
hkp02lp1802s-rs6000.hk.hsbc, 50000, ACMHKPU1:ACRMUTF
actcoreprod.us.hsbc, 1700, ACTCOREP
frloo10g1prd.systems.uk.hsbc, 1521, ADN00
ae0w0dic5073.hbeu.adroot.hsbc, 56091, AE0W0DIC5073\LIVE801MSSQL
MTW00130511.HBEU.ADROOT.HSBC, 1521, ARISTION
IGASMALTA.HBEU.ADROOT.HSBC, 1521, IGASDBL
ssuml527.systems.uk.hsbc, 1521, LMSPEGA1
Asset DBName
ora-abacogp.de.hsbc, 1626, ABACOGP ABACOGP
frlooraprda1.systems.uk.hsbc, 60002, ABM00 FRLOORAPRDA1
fr00parp0845ora.hibm.sub.fr.hsbc, 1521, ACC FR00PARP0845ORA
hkp02lp1802s-rs6000.hk.hsbc, 50000, ACMHKPU1:ACRMUTF HKP02LP1802
actcoreprod.us.hsbc, 1700, ACTCOREP ACTCOREPROD
frloo10g1prd.systems.uk.hsbc, 1521, ADN00 FRLOO10G1PRD
ae0w0dic5073.hbeu.adroot.hsbc, 56091, AE0W0DIC5073\LIVE801MSSQL AE0W0DIC5073
MTW00130511.HBEU.ADROOT.HSBC, 1521, ARISTION MTW00130511
IGASMALTA.HBEU.ADROOT.HSBC, 1521, IGASDBL IGASMALTA
ssuml527.systems.uk.hsbc, 1521, LMSPEGA1 SSUML527
正如你在第四行看到的那样,我的价值就像hkp02lp1802s
一样,在新栏目中,我最后不想要's',就像HKP02LP1802
一样。
答案 0 :(得分:0)
REGEXP_REPLACE应该符合您的需求:
https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions137.htm#SQLRF06302
如果需要更复杂的内容,请尝试此查询并调整正则表达式:
select
DBName,
regexp_replace(lower(Asset), '(' || lower(DBName) || ')[^.]', DBName)
from asset