ROUND (Expression)
The ROUND function returns Expression1 rounded to Expression2 places to the right of the decimal point.
SQL syntax
ROUND (Expression1 [,Expression2])
Parameters
ROUND has the parameters:
| Parameter | Description |
|---|---|
|
|
Operand or column can be any numeric type. |
|
|
Operand or column that indicates how many places to round. Can be negative to round off digits left of the decimal point. If you omit |
Description
-
If you omit
Expression2, the data type returned is the same as the numeric data type ofExpression1. -
If you specify
Expression2, the data type returned isNUMBERwith maximum precision and scale. -
If
Expression1is of typeBINARY_FLOATorBINARY_DOUBLE, the value ofExpression1is rounded to the nearest even value. Otherwise, the value ofExpression1is rounded away from 0 (for example, tox+1whenx.5is positive and tox-1whenx.5 is negative).
Examples
Round a number two places to the right of the decimal point.
Command> SELECT ROUND (15.5555,2) FROM dual; < 15.56 > 1 row found.
Round a number to the left of the decimal point by specifying a negative number for Expression2.
Command> SELECT ROUND (15.5555,-1) FROM dual; < 20 > 1 row found.
Round a floating point number. Floating point numbers are rounded to nearest even value. Contrast this to rounding an expression of type NUMBER where the value is rounded up (for positive values).
Command> SELECT ROUND (1.5f), ROUND (2.5f) FROM dual; < 2.00000000000000, 2.00000000000000 > 1 row found. Command> SELECT ROUND (1.5), ROUND (2.5) FROM dual; < 2, 3 > 1 row found.