I'm using the below SQL code in order to split the value of a column into another column but it is not working the way I expected. please find the below code along with the output which I'm getting.
Query:
select
upper(regexp_replace(regexp_substr(db_attributes,'.([^\.-]+),([^\,-]+), ([^\,-]+)[so]?[\,-]',1,1,'i',1),'[so]$','') ) AS servername, db_attributes
from table_name
Current Output:
servername db_attributes
HSBC bsprod04.hbtr.adroot.hsbc, 49465, BSPROD04\PTRFRDS01
NULL hkw00100308c01.hbap.adroot.hsbc, 2433, HKW00100308C01
NULL ora-abacogp.de.hsbc, 1626, ABACOGP
Desired Output:
servername db_attributes
BSPROD04\PTRFRDS01 bsprod04.hbtr.adroot.hsbc, 49465, BSPROD04\PTRFRDS01
HKW00100308C01 hkw00100308c01.hbap.adroot.hsbc, 2433, HKW00100308C01
ABACOGP ora-abacogp.de.hsbc, 1626, ABACOGP
Regards.