Purpose
This function returns the value of the numeric parameter truncated to the specified precision.
Syntax
TRUNC (numeric[,precision])
Parameters
Parameter |
Description |
|---|---|
| numeric | The number to be truncated, which is a NUMBER, FLOAT, BINARY_FLOAT, or BINARY_DOUBLE expression. |
| precision | The precision, which is an optional parameter. The default value is 0. It is a NUMBER, FLOAT, BINARY_FLOAT, or BINARY_DOUBLE expression.
|
Return type
If precision is not specified, the return type is the same as the data type of the numeric parameter. If precision is specified, the return type is NUMBER.
Examples
Truncate the number 555.666 with precision values of 2.2, -2, and 0.
obclient> SELECT TRUNC(555.666,2.2),TRUNC(555.666,-2),TRUNC(555.666) FROM DUAL;
+--------------------+-------------------+----------------+
| TRUNC(555.666,2.2) | TRUNC(555.666,-2) | TRUNC(555.666) |
+--------------------+-------------------+----------------+
| 555.66 | 500 | 555 |
+--------------------+-------------------+----------------+
1 row in set
