Eduardnol
Eduardnol

Reputation: 27

Take % out of an SQL column

I'm trying to convert 60% -> 60 of all the columns in a table. I have tried this, but it does not work because % is an SQL operator.

UPDATE host_info set host_response_rate = replace(host_response_rate,'%', '');

But I get all the values to be NULL...

I'm using postgresql

Upvotes: 0

Views: 71

Answers (1)

Gutemberg Schiessl
Gutemberg Schiessl

Reputation: 86

you can use this function, this take out the last n characters of a string. if you use 1, it will take out the last digit.

SELECT RIGHT(host_response_rate, 1)
FROM ...

Upvotes: 2

Related Questions