cyahahn
cyahahn

Reputation: 165

Convert field value from 1,000 to numeric

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!

Upvotes: 2

Views: 717

Answers (2)

This should work:

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

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

Upvotes: 1

Gordon Linoff
Gordon Linoff

Reputation: 1271151

You could remove the comma:

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

Upvotes: 1

Related Questions