15.02.2013 14:43, Johan De Meersman пишет:
>
> ----- Original Message -----
>> From: "Alex Keda" <admin@*stripped*>
>>
>> mysql> SELECT SUM(`Amount`*`Cost`*(1-`Discont`)) as `Summ` FROM
> `WorksCompliteAgregate` WHERE (`ContractID` = 10369 AND `Month` = 497);
> Based off the select you printed, this comes to EXACTLY 548.595 for the first row and
> 0 for the second row.
>
>
>> mysql> SELECT SUM(`Amount`*`Cost`*(1-`Discont`)*100)/100 as `Summ` FROM
> `WorksCompliteAgregate` WHERE (`ContractID` = 10369 AND `Month` = 497);
> The more detailed result here, though, seems to suggest that there's a longer
> fraction in your table than is printed by your select. Would your column happen to be a
> Float?
>
>> but, my desktop calculator gives the result 548.60
> Which is the correct rounding for 548.595. Check if your column is a float, and if it
> is, go google for floating point mathematics. They do not work the way you think they do.
> Use decimal(n,m) for money - or any discrete number, for that matter. Floats are not exact
> values, they are APPROXIMATE values.
>
> https://dev.mysql.com/doc/refman/5.0/en/problems-with-float.html may also give you an
> idea of what goes wrong.
>
>
OK. But, how about:
mysql> SELECT 365 * 1.67 * ( 1 - 0.10);
+--------------------------+
| 365 * 1.67 * ( 1 - 0.10) |
+--------------------------+
| 548.5950 |
+--------------------------+
1 row in set (0.00 sec)
mysql>
??