> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

> Reference material for ROUND function

# ROUND

Rounds a value to a specified number of decimal places.

## Syntax

```sql theme={"theme":{"light":"css-variables","dark":"css-variables"}}
ROUND(<value> [, <decimal>])
```

## Parameters

| Parameter   | Description                                                                                                                      | Supported input types |
| :---------- | :------------------------------------------------------------------------------------------------------------------------------- | :-------------------- |
| `<value>`   | The value to be rounded                                                                                                          |                       |
| `<decimal>` | Optional. An `INTEGER` constant that defines the decimal range of the returned value. By default, `ROUND` returns whole numbers. | `INTEGER`             |

## Return Types

`DOUBLE PRECISION`

## Rounding behavior

When rounding values that are exactly halfway between two possible results (for example, 1.5 or 2.5 when rounding to the nearest integer), `ROUND` uses different strategies depending on the data type:

* **DOUBLE PRECISION**: Uses banker's rounding (also called round half to even). Ties are rounded to the nearest even number. For example, both `1.5` and `2.5` round to `2` (the nearest even number).
* **NUMERIC**: Uses standard rounding (round half up). Ties are always rounded up. For example, `1.5` rounds to `2` and `2.5` rounds to `3`.

This behavior ensures that when working with floating point numbers, rounding errors don't accumulate in a particular direction over many operations.

## Example

The following example returns the rounded value of 5.4. Since there is no specification of the decimal range, the functions returns a whole number:

<div className="query-window">
  ```
  SELECT ROUND(5.4);
  ```

  | round <span>double</span> |
  | :------------------------ |
  | 5                         |

  <p><span>Rows: 1</span><span>Execution time: 7.16ms</span></p>
</div>

The following example rounds the value 5.6930 to 1 decimal place:

<div className="query-window">
  ```
  SELECT ROUND(5.6930, 1);
  ```

  | round <span>double</span> |
  | :------------------------ |
  | 5.7                       |

  <p><span>Rows: 1</span><span>Execution time: 5.46ms</span></p>
</div>

The following examples demonstrate the tie-breaking behavior for values exactly halfway between two results:

<div className="query-window">
  ```
  SELECT ROUND(1.5), ROUND(2.5);
  ```

  | round <span>double</span> | round <span>double</span> |
  | :------------------------ | :------------------------ |
  | 2                         | 2                         |

  <p><span>Rows: 1</span><span>Execution time: 5.73ms</span></p>
</div>

Notice how both `1.5` and `2.5` round to `2` (the nearest even number). This is banker's rounding behavior for `DOUBLE PRECISION` types.

With `NUMERIC` types, ties round up instead:

<div className="query-window">
  ```
  SELECT ROUND('1.5'::NUMERIC), ROUND('2.5'::NUMERIC);
  ```

  | round <span>Decimal(38, 9)</span> | round <span>Decimal(38, 9)</span> |
  | :-------------------------------- | :-------------------------------- |
  | 2.0                               | 3.0                               |

  <p><span>Rows: 1</span><span>Execution time: 5.45ms</span></p>
</div>

The same tie-breaking behavior applies when rounding to a specific number of decimal places:

<div className="query-window">
  ```
  SELECT ROUND(1.15, 1), ROUND(1.25, 1);
  ```

  | round <span>double</span> | round <span>double</span> |
  | :------------------------ | :------------------------ |
  | 1.2                       | 1.2                       |

  <p><span>Rows: 1</span><span>Execution time: 5.43ms</span></p>
</div>

Both `1.15` and `1.25` round to `1.2` when rounding to 1 decimal place, demonstrating banker's rounding.

With `NUMERIC` types at a specific decimal precision:

<div className="query-window">
  ```
  SELECT ROUND('1.15'::NUMERIC, 1), ROUND('1.25'::NUMERIC, 1);
  ```

  | round <span>Decimal(38, 9)</span> | round <span>Decimal(38, 9)</span> |
  | :-------------------------------- | :-------------------------------- |
  | 1.2                               | 1.3                               |

  <p><span>Rows: 1</span><span>Execution time: 10.61ms</span></p>
</div>
