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

# FORMAT_NUMBER

> Formats a number using digits or a decimal pattern.

<div className="e6-meta"><span className="e6-eyebrow e6-eyebrow--quiet">Scalar function</span></div>

NULL input/format or negative digits return NULL.

## Syntax

### Scalar

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
format_number(value, format)
```

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s) | Yes | The number. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |
| format | INTEGER or STRING | Yes | Fractional digits or DecimalFormat-subset pattern. |

## Returns

* Type: STRING
* Possible values: Formatted number.
* NULL behavior: NULL input/format or negative digits return NULL.

## Properties

| Property | Value |
| - | - |
| Deterministic | Yes |
| Supports window usage | No |
| Exact result | Yes |

## Usage notes

* Integer-digit form uses comma grouping and HALF\_UP rounding. NaN/infinities render NaN, Infinity, -Infinity. Pattern parses the positive section before a semicolon.
* Numeric input can be a signed integer, FLOAT, DOUBLE, or DECIMAL with up to 128-bit storage. Patterns support # and 0 digit placeholders, a decimal point, grouping commas, and literal prefixes or suffixes. Only the positive subpattern before a semicolon is used.
* INTEGER and INT mean the same type; STRING means VARCHAR text. NULL can be used with a supported type. Cast NULL explicitly when its type would otherwise be unclear.

## Examples

### Typical behavior

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT format_number(CAST(1234.5 AS DOUBLE), 2) AS "value";
```

| value |
| - |
| 1,234.50 |

### Round a negative number

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT format_number(CAST(-1234.567 AS DOUBLE), 2) AS formatted;
```

| formatted |
| - |
| -1,234.57 |

## Limitations

* Other decimal storage widths can raise an error. DECIMAL values with negative scale are printed as their unscaled integer. Very large scales can overflow or require too much memory. Very large floating-point values may return unformatted text.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.