Question and answer is powered by AnsPress.io
I have selected the sum of prices using the SUM() function from my MySQL database. I am trying with this line.
select("customer, SUM(price) as total_price")
Here, how can I set two decimal places in the MySQL select query?
You can apply the DECIMAL() function to select two decimal places of a number value.
If you want to set two decimal places in MySQL, apply this.
select("customer, SUM(CAST(price AS DECIMAL(11,2))) as total_price")