SELECT
CAST(‘1.505,00’ AS DECIMAL(10, 2)) AS result
Should return 1.51; the decimal point for floats is a .
You think you’re telling it to cast 1 thousand 505 as a decimal; what you’re actually telling it is to cast 1 point 505 as a decimal with two decimal places; so it correctly returns 1.51.
mysql> SELECT
ID,
A2,
ROUND(
CAST(
REPLACE (A2, ".", "") AS DECIMAL (10, 2)
),
2
) AS result
FROM
tbl_m
WHERE
ID = 833;
+-----+--------+--------+
| ID | a2 | result |
+-----+--------+--------+
| 833 | 843,33 | 843 |
+-----+--------+--------+
1 row in set
Why not see decimal in output result ?
Is not sufficient the round syntax?
thank you.