Sql REGEXP\u SUBSTR转换的输出未强制转换为整数
我尝试使用下面的REGEXP\u SUBSTR Sql函数从20个字符的字符串中提取所有数字Sql REGEXP\u SUBSTR转换的输出未强制转换为整数,sql,regex,casting,integer,amazon-redshift,Sql,Regex,Casting,Integer,Amazon Redshift,我尝试使用下面的REGEXP\u SUBSTR Sql函数从20个字符的字符串中提取所有数字 select REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 1) || REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 2) || REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 3) ... ... || REGEXP_SUBSTR(substr
select
REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 1)
|| REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 2)
|| REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 3)
...
...
|| REGEXP_SUBSTR(substring(mycolumn,1,20), '^[0-9]', 20)
from tbl;
但当尝试将其转换为bigint/decimal或任何数字数据类型时,由于类型numeric的输入语法无效,或无效数字,值“2”,位置0,类型:Long
等等
我错过什么了吗?REGEXP_SUBSTR串联的典型输出为1056220044022等。在红移数据仓库上运行的查询和REGEXP_REPLACE/TRANSLATE尚不存在。看起来每当字符串中没有数字时,上述REGEXP_SUBSTR串联将返回空字符串(“”)不支持将其强制转换为整数。所以我使用了NULLIF(regex表达式“”)