pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedRe: SUM PROBLEM...
2+ messages / 2 participants
[nested] [flat]
* Re: SUM PROBLEM...
@ 2002-05-09 16:25 David Stanaway <david@stanaway.net>
parent: Sonia Sanchez Diaz <sonny@piaget.dgsca.unam.mx>
0 siblings, 0 replies; 2+ messages in thread
From: David Stanaway @ 2002-05-09 16:25 UTC (permalink / raw)
To: Sonia Sanchez Diaz <sonny@piaget.dgsca.unam.mx>; +Cc: pgsql-admin
On Thu, 2002-05-09 at 12:48, Sonia Sanchez Diaz wrote:
>
> Hy!
>
> I have one money type field and I need to plus it, but when I run the
> query I get a negative answer!
>
> But I don't have negative numbers into this field...???
>
> What's up here??
>
> The query is:
>
> select sum(field) from table;
>
> and the answer is:
>
> field
> --------
> -$5,083,598.58
Sounds like you are getting an overflow.
http://www.postgresql.org/idocs/index.php?datatype-money.html
Type Name Storage Description Range
money 4 bytes Fixed-precision -21474836.48 to +21474836.47
NB: Its use is deprecated
Try using numeric:
http://www.postgresql.org/idocs/index.php?datatype.html#DATATYPE-NUMERIC-DECIMAL
I am not sure how you can convert the date to numeric, as on my database
(7.2.1) you cannot cast from money to numeric, or float (float would be
a bad idea for storage of monetary data).
select sum(m::numeric) from foo;
ERROR: Cannot cast type 'money' to 'numeric'
Maybe someone else could chime in at this point. : )
--
David Stanaway
Attachments:
signature.asc (application/pgp-signature, 523B) download
^ permalink raw reply [nested|flat] 2+ messages in thread
* SUM PROBLEM...
@ 2002-05-09 17:48 Sonia Sanchez Diaz <sonny@piaget.dgsca.unam.mx>
0 siblings, 1 reply; 2+ messages in thread
From: Sonia Sanchez Diaz @ 2002-05-09 17:48 UTC (permalink / raw)
To: pgsql-admin
Hy!
I have one money type field and I need to plus it, but when I run the
query I get a negative answer!
But I don't have negative numbers into this field...???
What's up here??
The query is:
select sum(field) from table;
and the answer is:
field
--------
-$5,083,598.58
Regards!
Sonny
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-05-09 17:48 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-09 17:48 SUM PROBLEM... Sonia Sanchez Diaz <sonny@piaget.dgsca.unam.mx>
2002-05-09 16:25 ` David Stanaway <david@stanaway.net>
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