View Single Post

   
  #4 (permalink)  
Old 02-28-2008, 08:31 AM
_mario.lat
 
Posts: n/a
Default Re: Wrong sum with float and group by

On Tue, 07 Nov 2006 06:40:48 -0500, Jerry Stuckle wrote:

> _mario.lat wrote:
>> Hallo,
>> I have a problem with a query like that:
>> SELECT SUM(price) as total FROM product GROUP BY type
>>
>> price is float or double.
>> total is not the exact sum.
>> How can I do?
>> Thank you in advance,
>> Mario.

>
> Mario,
>
> What do you mean "total is not the exact sum"?


Thankyou to all for answering (and reading) me.

If you have a table with the value:
type,price
a,1.2
b,0.1
c,3.4

real SUM (or real total) is 1.2+0.1+3.4 = 4.6
the query
SELECT SUM(price) as total FROM product GROUP BY type
give me: total 4.5 for example.

Thankyou again,
Mario.
Reply With Quote