Denis Matafonov
Denis Matafonov

Reputation: 2802

Postgres: Update field and round it

I have huge table where occasionally one column got not rounded values, e.g. 16345.462500 instead of 16345.460000

I'm not that good in postgres - maybe it's possible to update table rounding those values?

I can't change field type, because some rows (cryptocurrencies) can contain not rounded numbers.

Easiest thing I can think about is PHP script to manually update all fields.

Upvotes: 4

Views: 3199

Answers (1)

Mureinik
Mureinik

Reputation: 310983

You can use the round function to round to N decimal places - in your case, 2:

UPDATE mytable
SET    mycolumn = ROUND(mycolumn, 2)

Upvotes: 7

Related Questions