BULAT(X), BULAT(X,D)
SELECT ROUND(-1.23);
-1
SELECT ROUND(-1.58);
-2
SELECT ROUND(1.58);
2
SELECT ROUND(1.298, 1);
1.3
SELECT ROUND(1.298, 0);
1
SELECT ROUND(23.298, -1);
20
SELECT ROUND(.12345678901234567890123456789012345, 35);
0.123456789012345678901234567890
Rounds the argument X to D decimal places. The rounding algorithm depends on the data type of X. D defaults to 0 if not specified. D can be negative to cause D digits left of the decimal point of the value X to become zero. The maximum absolute value for D is 30; any digits in excess of 30 (or -30) are truncated. If X or D is NULL, the function returns NULL.
SELECT ROUND(-1.23);
-1
SELECT ROUND(-1.58);
-2
SELECT ROUND(1.58);
2
SELECT ROUND(1.298, 1);
1.3
SELECT ROUND(1.298, 0);
1
SELECT ROUND(23.298, -1);
20
SELECT ROUND(.12345678901234567890123456789012345, 35);
0.123456789012345678901234567890
The return value has the same type as the first argument (assuming that it is integer, double, or decimal). This means that for an integer argument, the result is an integer (no decimal places):
SELECT ROUND(150.000,2), ROUND(150,2);
+------------------+--------------+
| ROUND(150.000,2) | ROUND(150,2) |
+------------------+--------------+
| 150.00 | 150 |
+------------------+--------------+
ROUND() uses the following rules depending on the type of the first argument:
SELECT ROUND(2.5), ROUND(25E-1);
+------------+--------------+
| ROUND(2.5) | ROUND(25E-1) |
+------------+--------------+
| 3 | 2 |
+------------+--------------+