SQLite 3 reference · Math Functions

SQLite ROUND() Function

Round a number to a given number of decimal places (0 by default). Halves round away from zero.

SQLite 3

Create a free account to save this page, take notes and track your progress. Sign in

Syntax

round(X, Y)

Parameters

ParameterDescription
X A number (text that looks like a number is converted).
Y optional Decimal places to keep. Default: 0

Return value

A floating-point number, or NULL.

Examples

Round numbersTry it yourself
SELECT round(2.5) AS a, round(-2.5) AS b, round(3.14159, 2) AS c;

Output

a | b | c
3 | -3 | 3.14
Round an averageTry it yourself
SELECT round(avg(price), 2) AS avg_price
FROM products;

Output

avg_price
69.57

round() always returns a floating-point value. To get an integer, use CAST(round(x) AS INTEGER). To show exactly two decimals as text (2.50 rather than 2.5), use format('%.2f', x).

In other languages

Was this page helpful?