Hiya, I am trying to return some results from a mysql database (it's Magento, but that's not really important). I am trying to add up all the values in one column to get a grand total. I will save this query as a view, and then use the view in a project I am working on.
The query I am using is this:
SELECT sum(base_total_invoiced) as base_total_invoicedSum, state
FROM my_table_name
WHERE state="complete"
This returns the correct value, but it is to 4 decimal places. I would like to return this value only to 2 decimal places. It's a monetary value so looks a bit odd as 37567.0000
Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information.
Hi, I had seen that link on Stackoverflow when I was searching for solutions, but I can't tell from that if it's good practise to use TRUNCATE or not? Also I'm not sure where in my query I should place it.
what do you want trucated value or rounded value? either way it's all there in the mysql docs.
Regards, Mark.
Please search forums before posting. Please make sure your post includes the version of the CMS you are using and a link to the problem. Annotations on screenshots can also be helpful to explain problems/goals. Please use the "secure" tab for confidential information.