Reputation: 3
I am trying to remove all the zeros from the values of the attribute salary
.
I am using TRIM
function (by typecasting salary
into TEXT
). TRIM
function does not remove 0s that are in between, for example, if I use it on 809800
the result is '8098'
. The '0'
in the middle is still there.
Here is what I am doing:
Thanks in advance.
Upvotes: 0
Views: 719
Reputation: 1269523
You can use translate()
as well:
select translate(salary, '0', '')
For one character, this is just like replace()
. However, this generalizes more nicely to multiple characters. You can just list the characters instead of nesting calls to replace()
.
Upvotes: 0
Reputation: 23676
Use replace()
for that:
SELECT replace('01000200330004000', '0', '')
or for using with your salary
column:
SELECT replace(salary, '0', '')
Upvotes: 1