Jump to content

mysql query rounding incorrectly - adding 1 cent


dkmarsh99

Recommended Posts

HI. I have written a mysql database query to add up invoice totals. It seems to be automatilaly adding .01 to the result when I run a group by. Let me explain more ..

 

When I do a select on the field that I am adding up the result is $132.25 - the query is as follows

select ttl_invoice_due from 65_it where st_id = 96011;

 

When I run the following query that uses sum and group by - the $132.25 becomes $132.26 - the sum query is

 

SELECT 65_st.job_compid, 65_client.uid_client,  65_client.comp_name, Sum(65_it.ttl_invoice_due) AS SumOftotal_due, Sum(65_it.ttl_invoice) AS SumOftotal_invoice, Sum(65_it.ttl_invoice_payments) AS SumOftotal_amnt_paid FROM 65_client INNER JOIN (65_st INNER JOIN 65_it ON 65_st.st_id = 65_it.st_id) ON 65_client.uid_client = 65_st.uid_client WHERE   65_st.uid_client = 1905 and 65_st.job_compid = 1 and 65_st.sales_date<=curdate() GROUP BY 65_st.job_compid, 65_client.uid_client HAVING (((Sum(65_it.ttl_invoice_due))<>0)) order by 65_client.comp_name;

 

The 65_it.ttl_invoice_due field is defined in the table as Double(12,2)

 

I dont know why the sum is returing $132.26 where it should be $132.25 as in the simple query ?.

 

 



 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.