MySQL ROUND() Function

In MySQL, the ROUND() function rounds the specified number to the specified number of decimal places.

If you want to truncate decimal places by the number of digits, use the TRUNCATE() function.

If you want to return the integer part of a number, use FLOOR(), CEIL(), or CEILING().

ROUND() Syntax

Here is the syntax of MySQL ROUND() function:

ROUND(x, d)

Parameters

x
Required. The number to be rounded.
d
Required. The number of decimal places to round x to. The default is 0.

Return value

In MySQL, the ROUND() function rounds the specified number to the specified number of decimal places.

The ROUND() function will return NULL if any parameter is NULL.

ROUND() Examples

SELECT
    ROUND(123.179, 1),
    ROUND(123.179, 2),
    ROUND(123.179, 4),
    ROUND(123.179, 0),
    ROUND(123.179, -1),
    ROUND(123.179, -2),
    ROUND(123.179, NULL)\G

output

*************************** 1\. row ***************************
   ROUND(123.179, 1): 123.2
   ROUND(123.179, 2): 123.18
   ROUND(123.179, 4): 123.179
   ROUND(123.179, 0): 123
  ROUND(123.179, -1): 120
  ROUND(123.179, -2): 100
ROUND(123.179, NULL): NULL