Re: set decimal point in SQL

From: Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com>
To: rodgerd(at)diaspora(dot)gen(dot)nz, pgsql-sql(at)postgresql(dot)org
Subject: Re: set decimal point in SQL
Date: 2003-06-18 19:13:49
Message-ID: 20030618191349.45141.qmail@web20806.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

--- Rodger Donaldson <rodgerd(at)diaspora(dot)gen(dot)nz> wrote:
> On Mon, Jun 16, 2003 at 05:02:34PM -0500, Bu, Ning
> wrote:
>
> > I have a field set up as money and I try to
> calculate some number
> > and put in this field, but the number will be 6
> demical point and I
> > want to cut it to only 2-4 decimal point, how can
> I do it? Thanks
>
> round(); eg
>
> select round(foo, 2)
> from bar
>
> ...will give you values in column foo rounded to 2
> decimal places.
>

If you use "numeric(x,2)", where x is the largest
number of digits you are likely to need, the rounding
will be done for you. Type "money" is deprecated
anyway, and is likely to be dropped in a future
release. You can format the numeric value on output
if you want to display currency symbols or whatever.

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Marcin Winkler 2003-06-19 00:38:32 is this possible in plpgsql ?
Previous Message Rodger Donaldson 2003-06-18 19:02:16 Re: set decimal point in SQL