Oracle SQL中的数值过滤器

问题描述 投票:0回答:1

我只想过滤VARCHAR格式的值列表中的0-9数值

column:postal_Code
dhf65784ja!
s73;'235fsa
(kadf8(*45--

Expected Output
65784
73235
845

我尝试了以下操作:

SELECT distinct  
    postal_Code

FROM xx

where 1=1
and postal_Code!~ '[A-Z]' 
and postal_Code!~ '[a-z]' 
and postal_Code!~ '[-_º~@!"./#%£^$]' 

但是这不能给出正确的输出。

sql oracle
1个回答
2
投票

您可以使用regexp_replace

示例:

select regexp_replace(postal_Code, '[^0-9]', '') from xx;
© www.soinside.com 2019 - 2024. All rights reserved.