round()

Rounds x to s decimal places

Reference: Haybarn WASM 2.0.0-rc12

Arguments & returns

16 overloads

round(x)

Scalar
Overload link x Returns
#01 BIGINT BIGINT
#02 DECIMAL DECIMAL
#03 DOUBLE DOUBLE
#04 FLOAT FLOAT
#05 HUGEINT HUGEINT
#06 INTEGER INTEGER
#07 SMALLINT SMALLINT
#08 TINYINT TINYINT

round(x, precision)

Scalar
Overload link xprecision Returns
#09 BIGINTINTEGER BIGINT
#10 DECIMALINTEGER DECIMAL
#11 DOUBLEINTEGER DOUBLE
#12 FLOATINTEGER FLOAT
#13 HUGEINTINTEGER HUGEINT
#14 INTEGERINTEGER INTEGER
#15 SMALLINTINTEGER SMALLINT
#16 TINYINTINTEGER TINYINT

Round numbers to decimal places

Round a numeric value to a chosen number of decimal places. A negative precision rounds to tens, hundreds, or larger units.

NULL stays NULL. For exact decimal inputs, halfway values round away from zero.

Round numbers to decimal places
SQL
Haybarn WASM 2.0.0-rc12 ยท In your browser

Guide example ยท Run to view results.

Expected result
amountnearest_tenmissing
12.35130NULL

Watch for: Floating point values can be approximate. Use DECIMAL for examples where the exact decimal halfway point matters.

Example

round example
SQL
Haybarn WASM 2.0.0-rc12 ยท In your browser

Engine example ยท Run to view results.

In other engines

BigQueryround()

Same function

Snowflakeround()

Same function