---
title: round function
description: Learn the syntax of the round function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/round
---

# `round` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns the rounded `expr` using `HALF_UP` rounding mode.

## Syntax

```
round(expr [, targetScale] )
```

## Arguments

* `expr`: A numeric expression.
* `targetScale`: An `INTEGER` [constant expression](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-expression.md#constant-expression). If `targetScale` is omitted the default is 0 (whole number).

  In Databricks SQL and Databricks Runtime 12.2 LTS and above: If `targetscale` is negative rounding is performed to positive powers of `10`.

## Returns

If `expr` is `DECIMAL` the result is `DECIMAL` with a scale that is the smaller of `expr` scale and `targetScale`.
For all other numeric types, the result type matches `expr`.

In `HALF_UP` rounding, the digit 5 is rounded up.

For `HALF_EVEN` rounding use the [bround function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bround.md).

For integral numeric types Databricks raises an [ARITHMETIC\_OVERFLOW](https://docs.databricks.com/aws/en/error-messages/arithmetic-overflow-error-class.md) error when the rounded value overflows the result type.

> [!WARNING]
>
> In Databricks Runtime 12.2 LTS and below, and in Databricks Runtime if [spark.sql.ansi.enabled](https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-ansi-compliance.md) is `false`, an overflow does not cause an error but “wraps” the result instead.

## Common error conditions

* [ARITHMETIC\_OVERFLOW](https://docs.databricks.com/aws/en/error-messages/arithmetic-overflow-error-class.md)

## Examples

```sql
> SELECT bround(2.5, 0), round(2.5, 0);
 2    3

> SELECT bround(3.5, 0), round(3.5, 0);
 4    4

> SELECT bround(2.6, 0), round(2.6, 0);
 3    3

> SELECT bround(2.25, 1), round(2.25, 1);
 2.2  2.3

> SELECT bround(13.5, -1), round(13.5, -1);
 10   10

-- Rounding 127 to the nearest 10 produces 130, which overflows TINYINT.
> SELECT round(cast(127 AS TINYINT), -1);
  Error: ARITHMETIC_OVERFLOW
```

## Related functions

* [`floor` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/floor.md)
* [`ceiling` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/ceiling.md)
* [`ceil` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/ceil.md)
* [`bround` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bround.md)
