ROUND
Returns a number rounded to the specified number of decimal places.
PostgreSQL 17.5
ROUND(num[, decimals])Parameters
- numnumeric | double precision
- Number to round
- decimalsintegeroptional
- Number of decimal places, 0 by default, can be negative
Return value
A number of the same type as num; for an integer num, double precision without decimals and numeric with decimals
Examples
To a whole number
PostgreSQL 17.5
SELECT ROUND(27.89);To tenths
PostgreSQL 17.5
SELECT ROUND(27.89, 1);To tens
PostgreSQL 17.5
SELECT ROUND(27.89, -1);Rounding double precision
PostgreSQL 17.5
SELECT ROUND(SQRT(2)::numeric, 2);Details
A numeric value rounds halves away from zero: ROUND(2.5) returns 3. A double precision value usually rounds halves to even: ROUND(2.5::float8) returns 2. The decimals argument works only with numeric.