Skip to content
Advertisement

How to have exact decimal values without rounding in MySQL

I have this SQL script below:

select round (72.396, 2) 

What I expect like result is: 72.39.

I don’t want to round the number.

if I use the select round(72.396, 2) the result I get is: 72,40 How can I have what I expect without rounding using Mysql?

enter image description here

Advertisement

Answer

You need to use the truncate function instead of round:

SELECT TRUNCATE(72.396, 2) 

To answer the question in the comment – truncate just removes any additional decimal places after the number specified in the second argument, without rounding.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement