Numeric functions
Numeric functions operate on numeric values and perform operations such as rounding and truncation.
CEIL
Returns values from <input_expr>
rounded to the nearest equal or larger integer.
Syntax
CEIL( <input_expr> )
Returns
The return type is FLOAT.
Arguments
<input_expr>
The value or expression to operate on. The data type should be FLOAT.
Examples
SELECT CEIL(135.135), CEIL(-975.975), CEIL(2.5), CEIL(-2.5);
+---------------+-----------------+-----------+-------------+
| CEIL(135.135) | CEIL(- 975.975) | CEIL(2.5) | CEIL(- 2.5) |
+---------------+-----------------+-----------+-------------+
| 136.0 | -975.0 | 3.0 | -2.0 |
+---------------+-----------------+-----------+-------------+
FLOOR
Returns values from <input_expr>
rounded to the nearest equal or smaller integer.
Syntax
FLOOR( <input_expr> )
Returns
The return type is FLOAT.
Arguments
<input_expr>
The value or expression to operate on. The data type should be FLOAT.
Examples
SELECT FLOOR(135.135), FLOOR(-975.975), FLOOR(2.5), FLOOR(-2.5);
+----------------+------------------+------------+--------------+
| FLOOR(135.135) | FLOOR(- 975.975) | FLOOR(2.5) | FLOOR(- 2.5) |
+----------------+------------------+------------+--------------+
| 135.0 | -976.0 | 2.0 | -3.0 |
+----------------+------------------+------------+--------------+
ROUND
Returns rounded values for <input_expr>
. If the fractional part is exactly 0.5, the result is rounded away from zero.
Syntax
ROUND( <input_expr> )
Returns
The return type is FLOAT.
Arguments
<input_expr>
The value or expression to operate on. The data type should be FLOAT.
Examples
SELECT ROUND(135.135), ROUND(-975.975), ROUND(2.5), ROUND(-2.5);
+----------------+------------------+------------+--------------+
| ROUND(135.135) | ROUND(- 975.975) | ROUND(2.5) | ROUND(- 2.5) |
+----------------+------------------+------------+--------------+
| 135.0 | -976.0 | 3.0 | -3.0 |
+----------------+------------------+------------+--------------+
TRUNC
Rounds the input expression down to the nearest (or equal) integer closer to zero.
Syntax
TRUNC( <input_expr> )
Returns
The return type is FLOAT.
Arguments
<input_expr>
The value or expression to operate on. The data type should be FLOAT.
Examples
SELECT TRUNC(135.135), TRUNC(-975.975), TRUNC(2.5), TRUNC(-2.5);
+----------------+------------------+------------+--------------+
| TRUNC(135.135) | TRUNC(- 975.975) | TRUNC(2.5) | TRUNC(- 2.5) |
+----------------+------------------+------------+--------------+
| 135.0 | -975.0 | 2.0 | -2.0 |
+----------------+------------------+------------+--------------+