Oracle® TimesTen In-Memory Database SQL Reference Release 11.2.1 Part Number E13070-03 |
|
|
View PDF |
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 |
---|---|
Expression1 |
Operand or column can be any numeric type. |
Expression2 |
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 Expression2 , then Expression1 is rounded to 0 places. Must be an integer. |
Description
If you omit Expression2,
and Expression1
is of type TT_DECIMAL, the data type returned is NUMBER with maximum precision and scale. Otherwise, if you omit Expression2
, the data type returned is the same as the numeric data type of Expression1
.
If you specify Expression2
, the data type returned is NUMBER with maximum precision and scale.
If Expression1
is of type BINARY_FLOAT or BINARY_DOUBLE, the value of Expression1
is rounded to the nearest even value. Otherwise, the value of Expression1
is rounded away from 0 (for example, to x+1 when x.5 is positive and to x-1 when x.5 is negative).
Examples
Round a number 2 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.