SQLite round() Function
The SQLite round() function rounds the given number to the specified number of decimal places and returns the result.
Syntax
Here is the syntax of the SQLite round() function:
round(x, d)
Parameters
x-
Required. The number to round.
d-
Optional. The number of decimal places to retain. The default is 0.
Return value
The SQLite round() function rounds the specified number to the specified number of decimal places.
- If
dis greater than or equal to the number of decimal places ofx, the original number is returned. - If is
dless than the number of decimal places ofx, round the number of decimal places ofxtodreturn. - If
dis negative,dis treated as0. - The
round()function will returnNULLif either parameter isNULL.
Examples
This example shows how to use round() the basic usage of the SQLite function:
SELECT
round(123.179, 1),
round(123.179, 2),
round(123.179, 4),
round(123.179, 0),
round(123.179, -1),
round(123.179, -2);
round(123.179, 1) = 123.2
round(123.179, 2) = 123.18
round(123.179, 4) = 123.179
round(123.179, 0) = 123.0
round(123.179, -1) = 123.0
round(123.179, -2) = 123.0