I have a table:
create table payments
(
id serial constraint payments_pkey primary key,
amount real not null
);
There are some data:
amount
79740.03
4430.64
95429.1
1567.73
206959.31
I need to sum amount. For that I use sum
:
select sum(payments.amount)
from payments
It gives me 388126.8 but I expect 388126.81.
But if I execute query with casting:
select sum(cast(cast(payments.amount as text) as decimal))
from payments
then it gives me expected sum 388126.81.
What’s wrong with first query?