The ROUND()
function rounds a number off to a specified number of decimal places.
Figure 1 shows a visual representation of the ROUND()
function.
ROUND(number, decimals)
The ROUND()
function has two parameters:
SIGN()
returns the number rounded off to the specified number of decimal places.
If the decimals parameter is omitted, then
SIGN()
returns the nearest integer value of a number sent as a parameter (no decimal places).
If you input a negative value (
n
) in the decimalparameter, then
ndigits to the left of the decimal point of the number parameter will change to
0`.
/*example showing how to use ROUND(X)*/-- positive: number positive: decimalsSELECT ROUND(102.3456, 2);-- positive: number negative: decimalsSELECT ROUND(112.3456, -1);-- neagtive: number positive: decimalsSELECT ROUND(-102.3456, 3);-- neagtive: number negative: decimalsselect ROUND(-6.13, -1);-- omit decimalsselect ROUND(12.234);