Page 1 of 1

2 floating numbers substract in a query

Posted: Sun May 15, 2005 12:13 am
by pelegk2
have this query :

Code: Select all

SELECT costumers.id as cID,sum(users_payment .total_bill-actuall_payed) 
from costumers 
LEFT JOIN users_payment ON users_payment.userid=costumers.id  AND users_payment.month<5 
group by cID 
LIMIT 0, 50


in the first result i get instead of 92 i get : 91.199996948242
what can i do to prevent this? and get the correct answer?
by the way in the first line i am adding 2 number : 45.5 and 46.5=92
so whats the solution
tnaks in advance
peleg

Posted: Sat May 28, 2005 4:00 pm
by JAM
Well, you could use abs(sum(users_payment.total_bill-actuall_payed)) or similiar if you need to strip of the decimals, but there is also CEIL() and FLOOR() depending on preference (discounts, goodwill aso aso).

Browse the math functions that mysql uses and you might find something that fits you better.