SQLite ROUND function

The SQLite ROUND function is used to round a given numeric value to a specified number of decimal places. This function takes two arguments: the first argument is the value that needs to be rounded, and the second argument is the number of decimal places to which the value should be rounded.

Syntax

The syntax for the SQLite ROUND function is as follows:

ROUND (value, decimal_places)

where value is the numeric value that needs to be rounded, and decimal_places is the number of decimal places to which the value should be rounded.

Example

Here’s an example of how to use the ROUND function in SQLite:

SELECT ROUND(12.345, 2);

In this example, the value 12.345 will be rounded to two decimal places, resulting in the value 12.35.

It’s worth noting that the ROUND function in SQLite follows the standard rounding rules. Specifically, if the number to be rounded is exactly halfway between two possible rounding values, then the function will round to the nearest even number. For example, if we round 2.5 to one decimal place, the result will be 2.4, since 4 is the nearest even number.

In addition to the ROUND function, SQLite also provides other rounding functions, such as CEIL (which rounds up to the nearest integer) and FLOOR (which rounds down to the nearest integer).