8.2.19. ROUND()
Available in
DSQL, PSQL
Possible name conflict
YES → Read details
Syntax
ROUND (number [, scale])
Parameter | Description |
---|---|
number | An expression of a numeric type |
scale | An integer specifying the number of decimal places toward which rounding is to be performed, e.g.:
|
Result type
INTEGER
, (scaled) BIGINT
or DOUBLE PRECISION
Description
Rounds a number to the nearest integer. If the fractional part is exactly 0.5
, rounding is upward for positive numbers and downward for negative numbers. With the optional scale argument, the number can be rounded to powers-of-ten multiples (tens, hundreds, tenths, hundredths, etc.) instead of just integers.
If you are used to the behaviour of the external function |
Examples
If the scale argument is present, the result usually has the same scale as the first argument:
ROUND(123.654, 1) -- returns 123.700 (not 123.7)
ROUND(8341.7, -3) -- returns 8000.0 (not 8000)
ROUND(45.1212, 0) -- returns 45.0000 (not 45)
Otherwise, the result scale is 0:
ROUND(45.1212) -- returns 45