Convert field value from 1,000 to numeric

Viewed 122

I have a field called "sales" and the source data is piping in a value with a comma (ex: 1,000) instead of 1000 (without commas).

How can I convert this value to a numeric (without commas)?

Thanks in advance!

2 Answers

You could remove the comma:

select replace(sales, ',', '')::numeric

This should work:

select replace(sales, ',', '')::numeric from tablename; 

replace(sales, ',', '') to remove commas (',') and ::numeric to convert value to numeric.

Related