I have a column where the strings are in the following format: " 12.05% "
I need to do some calculations with these values, and I'm formatting the values that are acceptable for float / double format etc.
I have the following line in my query:
cast(replace(replace(replace(campo, '%', ''), '.', ''), ',', '.') as float)
It performs as expected without problems, but this column has null values or no value, in case they do not have any number so they can be converted to float and this ends up generating an error, I need to treat those values so that they receive " 0 ".
ERROR: invalid input syntax for type double precision: ""