- If all the data within that column is composed of integers, integers with leading and/or trailing whitespaces, null values and only whitespaces then only using
TRIM()
function will suffice such as
SELECT TRIM(columnA)
FROM t
and that would be more performant than using functions of regular expressions
But
- If the data contains decimal numbers, letters, punctiations and special characters along with whitespaces and null values, then use
SELECT TRIM('.' FROM REGEXP_REPLACE(columnA,'[^[:digit:].]'))
FROM t
where there is at most one dot character assumed to be between the starting and ending digits. All of the leading and trailing dots are trimmed at the end of the operation provided there is any of them. The other characters are already removed by the regular expression.
- If you're sure that there's no trailing or leading dots, then using
SELECT REGEXP_REPLACE(columnA,'[^[:digit:].]')
FROM t
would be enough
Demo
You can wrap up any of the expressions with TO_NUMBER()
function depending on your case at the end