Re: Money in numeric field - Mailing list pgsql-general

From Albe Laurenz
Subject Re: Money in numeric field
Date
Msg-id D960CB61B694CF459DCFB4B0128514C207C34244@exadv11.host.magwien.gv.at
Whole thread Raw
In response to Money in numeric field  (Martín Marqués <martin.marques@gmail.com>)
Responses Re: Money in numeric field  (Martín Marqués <martin.marques@gmail.com>)
List pgsql-general
Martín Marqués wrote:
> I have a question involving money data stored in a numeric(9,2) field,
> and posible errors with there manipulation.
> 
> in short, the table has these columns:
> 
> store: int
> amount: int2
> cost: numeric(9,2)
> 
> What I need to find is the total amount of money spent in a particular
> store, so I do something like the second query:
> 
> SELECT count(*) from material where store = 9;
>  count
> -------
>    360
> (1 fila)
> 
> SELECT sum(cost*amount) from material where store = 9;
>    sum
> ----------
>  48244.35
> (1 fila)
> 
> 
> Is it posible to have errors after multipling the numeric value by and
> int and then adding them all with the SUM() function?

Not really.
"numeric" represents numbers exactly up to 131072 digits before
the decimal point and up to 16383 digits after the decimal point.

Yours,
Laurenz Albe

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Problem with reading data from standby server ?
Next
From: "F. BROUARD / SQLpro"
Date:
Subject: Why did pg_relation_filepath does not give a correct path ?