ROUND
Returns a number rounded to the specified number of decimal places.
PostgreSQL 17.9
ROUND(num[, decimals])- [ ]optional part
- num
- Number to roundnumeric | double precision
- decimals
- Decimal places, 0 by default; a negative value rounds to tens, hundreds…integerOptional
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.9
SELECT ROUND(27.89);To tenths
PostgreSQL 17.9
SELECT ROUND(27.89, 1);To tens
PostgreSQL 17.9
SELECT ROUND(27.89, -1);Rounding double precision
PostgreSQL 17.9
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.