PostgreSQL 18 reference · Math Functions

PostgreSQL ROUND() Function

Round a number to a given number of decimal places (0 by default). numeric rounds halves away from zero.

PostgreSQL 18

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

Syntax

round(x)  |  round(x numeric, places)

Parameters

ParameterDescription
x A number (integer, numeric or double precision).
places optional Decimal places; negative rounds to tens, hundreds…. Default: 0

Return value

A number of the input type.

Examples

Round numbers
SELECT round(2.5) AS a, round(-2.5) AS b, round(3.14159, 2) AS c, round(1234.5, -2) AS d;

Output

 a | b  |  c   |  d
---+----+------+------
 3 | -3 | 3.14 | 1200
(1 row)

Run this on your computer — see “Get Started” for setup.

double precision rounds halves to even
SELECT round(2.5::double precision) AS float_half, round(2.5::numeric) AS numeric_half;

Output

 float_half | numeric_half
------------+--------------
          2 |            3
(1 row)

Run this on your computer — see “Get Started” for setup.

round(x, places) only exists for numeric, so cast floating-point values first: round(avg(price)::numeric, 2).

In other languages

Was this page helpful?