I have an application that handle integration among marketplaces. Precision is very desirable because, for example, one customer may buy 1099 times a product costing 0.93. Resulting in 1022.07. Afterwards I will have to make some statistics for example 1022.07 divided by 5 leading to 204.414. I want to say is that I will have decimal issues for sure. Which data type should I use to be more accurate and specially which data type should I use to have less work to handle monetary in Postgres. I am brazilian and I saw money data type I don't know if it is an ANSI data type but I don't like the Idea of having a character appended to the numeric data. My question is not about the money data type. I just want to know a good data type for my system.
Asked
Active
Viewed 23 times
0
-
1You almost certainly want "numeric" but the exact number of decimal places will depend on how these marketplaces do their calculations. https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-NUMERIC-DECIMAL – Richard Huxton Jul 08 '23 at 13:10
-
1Agreed, you want "numeric", but whatever you do [Don't Use Money](https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_money) – Belayer Jul 09 '23 at 02:20