> ## 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.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/numeric/round",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference material for ROUND function

# ROUND

export const QueryWindow = ({content}) => {
  const {sql, result} = content;
  const [inited, setInited] = useState(false);
  const buttonRef = useRef(null);
  useEffect(() => {
    if (!inited && buttonRef.current) {
      runQuery(buttonRef.current, true);
      setInited(true);
    }
  }, []);
  return <div className="query-window">
      <div className="query-toolbar">
        <button className="run-button" onClick={ev => runQuery(ev.target)} ref={buttonRef}>Run Query</button>
        <span className="window-title">Interactive SQL Playground 🔥</span>
      </div>
      <div className="query-content">
        <pre><code className="firebolt-sql language-sql" contentEditable="true" spellCheck="false" data-original-query={sql}>{sql}</code></pre>
        <script type="application/json" className="fallback-result" style={{
    display: "none"
  }}>{JSON.stringify(result)}</script>
        <div className="server-unavailable-banner query-window-hidden">
          The Firebolt playground server is currently unavailable. Using precomputed query results.
        </div>
        <div className="query-results"></div>
      </div>
    </div>;
};

Rounds a value to a specified number of decimal places.

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
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:

<QueryWindow
  content={{
"sql": "SELECT ROUND(5.4);",
"result": {
"data": [
  [
    5
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "22d5418c-efc0-4f7f-b3eb-38462359db66",
  "query_label": null,
  "request_id": "e39fdc0c-5660-446a-a184-14c21ea59acf"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.006589,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000246822,
  "time_to_execute": 8.6677e-05
}
}
}}
/>

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

<QueryWindow
  content={{
"sql": "SELECT ROUND(5.6930, 1);",
"result": {
"data": [
  [
    5.7
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "10b68efe-d0dd-43d9-b205-3c952445a0a6",
  "query_label": null,
  "request_id": "9da5ab0b-252a-4c19-a769-0d50839b6f2a"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.009415,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000277506,
  "time_to_execute": 8.9093e-05
}
}
}}
/>

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

<QueryWindow
  content={{
"sql": "SELECT ROUND(1.5), ROUND(2.5);",
"result": {
"data": [
  [
    2,
    2
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  },
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "add86cbb-b720-46bd-bc9c-5d41e8569659",
  "query_label": null,
  "request_id": "740bc416-3591-48b6-9266-33c4f75fa2b3"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.051668,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000353221,
  "time_to_execute": 0.000164879
}
}
}}
/>

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:

<QueryWindow
  content={{
"sql": "SELECT ROUND('1.5'::NUMERIC), ROUND('2.5'::NUMERIC);",
"result": {
"data": [
  [
    2.0,
    3.0
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "Decimal(38, 9)"
  },
  {
    "name": "?column?",
    "type": "Decimal(38, 9)"
  }
],
"query": {
  "query_id": "ab10ac81-34e9-4699-90ad-c9eb0ca8cb66",
  "query_label": null,
  "request_id": "35540062-2956-4aa3-91c2-8ae2c12129a2"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.050091,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000379714,
  "time_to_execute": 0.000191272
}
}
}}
/>

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

<QueryWindow
  content={{
"sql": "SELECT ROUND(1.15, 1), ROUND(1.25, 1);",
"result": {
"data": [
  [
    1.2,
    1.2
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  },
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "b16898c6-7154-4084-9f95-e8a4e1f0d88a",
  "query_label": null,
  "request_id": "91104345-97da-4f2a-9c47-7f8f10cb81b1"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.050776,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000257156,
  "time_to_execute": 0.000114328
}
}
}}
/>

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:

<QueryWindow
  content={{
"sql": "SELECT ROUND('1.15'::NUMERIC, 1), ROUND('1.25'::NUMERIC, 1);",
"result": {
"data": [
  [
    1.2,
    1.3
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "Decimal(38, 9)"
  },
  {
    "name": "?column?",
    "type": "Decimal(38, 9)"
  }
],
"query": {
  "query_id": "5a0c701a-adff-40d4-8d1a-4679bcddfc11",
  "query_label": null,
  "request_id": "02199ef5-304c-402d-a706-054c8a329baa"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.052036,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000278404,
  "time_to_execute": 0.000126126
}
}
}}
/>
