bround function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Returns the rounded expr using HALF_EVEN rounding mode.

Syntax

bround(expr [,targetScale] )

Arguments

  • expr: A numeric expression.

  • targetScale: An INTEGER expression greater or equal to 0. If targetScale is omitted the default is 0.

Returns

If expr is DECIMAL the result is DECIMAL with a scale that is the smaller of expr scale and targetScale.

In HALF_EVEN rounding, also known as Gaussian or banker’s rounding, the digit 5 is rounded towards an even digit.

Examples

> SELECT bround(2.5, 0);
 2
> SELECT bround(2.6, 0);
 3
> SELECT bround(3.5, 0);
 4
> SELECT bround(2.25, 1);
 2.2