I’m trying to alter a table with values like below. The data type is a string but I want to change it to numbers.
ALTER TABLE data ALTER COLUMN value TYPE NUMERIC(7,2) USING value::numeric ERROR: invalid input syntax for type numeric: "1,000.00" SQL state: 22P02
Advertisement
Answer
Well, the simple conversion doesn’t work. One method would be:
using replace(value, ',', '')::numeric