Gladiador
Gladiador

Reputation: 129

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

Upvotes: 0

Views: 2052

Answers (1)

Mureinik
Mureinik

Reputation: 311403

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.

Upvotes: 5

Related Questions