MySQL ROUND() function
ROUND() function
MySQL ROUND() rounds a number specified as an argument up to a number specified as another argument.
Syntax:
ROUND(N,[D]);
Argument:
Name | Description |
---|---|
N | A number which will be rounded upto D decimal places. |
D | A number indicating up to how many decimal places N will be rounded. |
Note: The arguments can be zero(0) or negative. The default value of ‘D’ is 0 if not specified. if ‘D’ is 0, the round will happen from the left of the ‘D’ decimal point of the value ‘N’.
Syntax Diagram:

MySQL Version: 5.6
Pictorial presentation of MySQL ROUND() function
Example of MySQL ROUND() function
Code:
SELECT ROUND(4.43);
Explanation:
The above MySQL statement will round the given number 4.43. No decimal places have been defined, so the default decimal value is 0.
Sample Output:
mysql> SELECT ROUND(4.43); +-------------+ | ROUND(4.43) | +-------------+ | 4 | +-------------+ 1 row in set (0.00 sec)
Example: ROUND() function with negative value
Code:
SELECT ROUND(-4.53);
Explanation:
The above MySQL statement will round the given number -4.53. No decimal places have been defined, so the default decimal value is 0.
Sample Output:
mysql> SELECT ROUND(-4.53); +--------------+ | ROUND(-4.53) | +--------------+ | -5 | +--------------+ 1 row in set (0.00 sec)
Example: ROUND() function using decimal places
Code:
SELECT ROUND(-4.535,2);
Explanation:
The above MySQL statement will round the given number -4.535 up to 2 decimal places.
Sample Output:
mysql> SELECT ROUND(-4.535,2); +-----------------+ | ROUND(-4.535,2) | +-----------------+ | -4.54 | +-----------------+ 1 row in set (0.00 sec)
Example: ROUND() function using negative decimal places
Code:
SELECT ROUND(34.4158,-1);
Explanation:
The above MySQL statement will round the given number 34.4158 from the left of decimal place up to 1 place.
Sample Output:
mysql> SELECT ROUND(34.4158,-1); +-------------------+ | ROUND(34.4158,-1) | +-------------------+ | 30 | +-------------------+ 1 row in set (0.00 sec)
All Mathematical Functions
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- JavaScript functions Exercises
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook