Re: Best data type to use for sales tax percent

From: "Roderick A(dot) Anderson" <raanders(at)cyber-office(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Best data type to use for sales tax percent
Date: 2009-10-10 14:53:33
Message-ID: 4AD09FED.4030407@cyber-office.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jasen Betts wrote:
> On 2009-10-09, Peter Eisentraut <peter_e(at)gmx(dot)net> wrote:
>> On Fri, 2009-10-09 at 11:46 -0700, Christophe Pettus wrote:
>>> Domains are basically type aliases with an optional CHECK clause, so
>>> you could do something like:
>>>
>>> CREATE DOMAN sales_tax_rate AS DECIMAL(5,5) CHECK (VALUE >= 0);
>>>
>>> Then, you can use the type "sales_tax_rate" in your tables, etc. just
>>> as a normal first-class type. (The only limitation, right now, is
>>> that you can't create an array of them.)
>> Actually I wouldn't bother with the precision and scale at all. I'd go
>> with something like
>>
>> CREATE DOMAN sales_tax_rate AS DECIMAL CHECK (VALUE >= 0 AND VALUE <=1);
>
> why the latter check ( VALUE <=1 )?

I think the initial post implied it was to be used directly in the
calculations, no "sales_tax_rate/100", so a fraction is needed.
Hopefully no one is experiencing 99%+ tax rates.

\\||/
Rod
--

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Michal Szymanski 2009-10-10 15:05:32 Re: transaction ID wraparound - should I use 'VACUUM' or 'VACUUM FULL' ?
Previous Message Jasen Betts 2009-10-10 10:42:01 Re: bulk inserts