Jump to: navigation, search

Mysql ROUND

From w3cyberlearnings

Contents

MySQL ROUND Function

This function rounds a given number to D decimal places for two parameters input. For single parameter, it is round to the nearest integer. The rule for the ROUND function is that it round half up or round toward nearest. A value is a fraction of .5.

Syntax ROUND

ROUND(X);

OR

ROUND(X,Y);

Example 1

mysql> SELECT ROUND(2.2);
+------------+
| ROUND(2.2) |
+------------+
|          2 |
+------------+
1 row in set (0.00 sec)

Example 2

mysql> SELECT ROUND(14.13,3);
+----------------+
| ROUND(14.13,3) |
+----------------+
|         14.130 |
+----------------+
1 row in set (0.00 sec)


Example 3

mysql> SELECT ROUND(-2.2);
+-------------+
| ROUND(-2.2) |
+-------------+
|          -2 |
+-------------+
1 row in set (0.00 sec)

Related Links


Navigation
Web
SQL
MISC
References