I want to cast string into Integer. I have a table like this.
Have:
ID Salary
1 "$1,000"
2 "$2,000"
Want:
ID Salary
1 1000
2 2000
My query
Select Id, cast(substring(Salary,2, length(salary)) as int)
from have
I am getting error.
ERROR: invalid input syntax for type integer: "1,000"
SQL state: 22P02
Can anyone please provide some guidance on this.
SELECT REGEXP_REPLACE(salary, ',|\$', '', 'g')::INT FROM test;SELECT to_number(salary, 'L99999999999') FROM test;