|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I have table with the following columns:
customer int4 NOT NULL amount float8 NOT NULL And among others I got these rows: customer..amount 1118........9907.6 1118........29722.8 1118........-9907.6 1118........-29722.8 the correct sum for: select sum(amount) from myTable where customer =1118; should be 0. But the sum I get is 3.63797880709171e-12 I get this result from pgAdmin (running on Win2000), from my Delphi application and from psql running on Linux. I have also moved the same database to Win2000 using Cygwin. Do anyone have a solution og explanation? - Eirik |
|
#2
|
|||
|
|||
|
Explanation: float fields are stored in scientific notation and as such are subject to rounding errors, which is what you are experiencing.
Solution: use NUMERIC |
![]() |
| Viewing: Dev Shed Forums > Databases > PostgreSQL Help > select sum() is not giving the correct sum |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|