Re: Best data type to use for sales tax percent

From: Mike Christensen <mike(at)kitchenpc(dot)com>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Best data type to use for sales tax percent
Date: 2009-10-08 23:50:47
Message-ID: 7aa638e00910081650v401582f8yd749973d374dfcbb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Oops sorry I was thinking 2,3 meant 2 significant digits to the left
of the decimal point and 3 to the right. I just re-read the docs and
now see what you mean. 6,3 would work fine though is maybe a bit
overkill since a 100% sales tax rate would cause a violent revolution
and lead to beheadings, at which point Postgres data integrity would
be the least of our worries..

I'll probably just use 3,3 and store this value between 0 and 1, since
all I'll be doing with this number is using it to multiply against a
subtotal. 3,3 gives me 0.000 through 0.999, correct?

Mike

On Thu, Oct 8, 2009 at 4:38 PM, Merlin Moncure <mmoncure(at)gmail(dot)com> wrote:
> On Thu, Oct 8, 2009 at 6:04 PM, Mike Christensen <mike(at)kitchenpc(dot)com> wrote:
>> (Sorry for the super-easy question)
>>
>> I want to store sales tax (as a percent) in the DB, such as 9.5%.
>> What's the best data type for this?  I'm guessing numeric(2,3) should
>> be fine, yes?  I'm not too familiar with the numeric type (I was using
>> "real" before), but as I understand the data will be stored using the
>> necessary number of bits on the disk?  Thanks!
>
> numeric(2,3) is not possible :-). IMO, a percentage should be stored
> numeric(6,3) or so.  That gives up to 100% down to thousandth of a
> percent.
>
> merlin
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2009-10-08 23:54:57 Re: How to reduce WAL file Size
Previous Message Merlin Moncure 2009-10-08 23:38:28 Re: Best data type to use for sales tax percent