来源专栏
Id | email
_______________________
01 | aemail1, wemail2
02 | bemail1 : xemail2
03 | cemail1 yemail2
04 | demail1&zemail2
目标栏
Id | primary_email| secondary_email
01 | aemail1 | wemail2
02 | bemail1 | xemail2
03 | cemail1 | yemail2
04 | demail1 | zemail2
在某些情况下< space>如果不是pl / SQL,我们也可以使用SQL做分隔符请帮我解决这个问题
答案 0 :(得分:0)
您可以使用正则表达式将电子邮件拆分为两个。
此示例拆分一个或多个连续分隔符, or space or &
select
ID,
regexp_replace(EMAIL, '^(.*)[,\s&]+.*', '\1') AS PRIMARY_EMAIL,
regexp_replace(EMAIL, '.*[,\s&]+(.*)', '\1') AS SECONDARY_EMAIL
from TABLE_NAME