pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedset decimal point in SQL
3+ messages / 3 participants
[nested] [flat]
* set decimal point in SQL
@ 2003-06-16 22:02 Bu, Ning <NBU@pcgus.com>
0 siblings, 1 reply; 3+ messages in thread
From: Bu, Ning @ 2003-06-16 22:02 UTC (permalink / raw)
To: pgsql-sql
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
Attachments:
image001.jpg (image/jpeg, 2.9K) download
view image
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: set decimal point in SQL
@ 2003-06-18 19:02 Rodger Donaldson <rodgerd@diaspora.gen.nz>
parent: Bu, Ning <NBU@pcgus.com>
0 siblings, 1 reply; 3+ messages in thread
From: Rodger Donaldson @ 2003-06-18 19:02 UTC (permalink / raw)
To: pgsql-sql
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.
--
Rodger Donaldson rodgerd@diaspora.gen.nz
I don't mind straight people, as long as they act gay in public
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: set decimal point in SQL
@ 2003-06-18 19:13 Jeff Eckermann <jeff_eckermann@yahoo.com>
parent: Rodger Donaldson <rodgerd@diaspora.gen.nz>
0 siblings, 0 replies; 3+ messages in thread
From: Jeff Eckermann @ 2003-06-18 19:13 UTC (permalink / raw)
To: rodgerd@diaspora.gen.nz; pgsql-sql
--- Rodger Donaldson <rodgerd@diaspora.gen.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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2003-06-18 19:13 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-16 22:02 set decimal point in SQL Bu, Ning <NBU@pcgus.com>
2003-06-18 19:02 ` Rodger Donaldson <rodgerd@diaspora.gen.nz>
2003-06-18 19:13 ` Jeff Eckermann <jeff_eckermann@yahoo.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox