In PostgreSQL, which field to use for percentage?

4

In the table I am creating, I will have a column that will indicate the discount percentage, for example, "for a certain agreement I will have a 20% discount, for another agreement I will have a 50% discount", and I will need to use it in calculations for final cost, I would like to know what field type should I use to save this percentage? I thought about using decimal but I was in doubt.

    
asked by anonymous 27.02.2015 / 15:36

1 answer

3

If it has no decimal places you can use integer or smallint , otherwise decimal is a good choice. Just do not use real or anything like that. I think you already know that this guy has problems with financial calculations.

    
27.02.2015 / 15:41