> ## 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/ceil",
  "feedback": "Description of the issue"
}
```

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

</AgentInstructions>

> Reference material for CEIL, CEILING functions

# CEIL

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 an input `<value>` up to the nearest multiple based on the specified precision or decimal place. Optionally, you can specify a second parameter to determine which decimal place the value should be rounded up to.

**Alias:** `CEILING`

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
CEIL(<value>);
CEIL(<value>, <digit>);
```

OR

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
CEILING(<value>);
CEILING(<value>, <digit>);
```

## Parameters

| Parameter | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Supported input types         |
| :-------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------- |
| `<value>` | The number to be rounded up to the nearest specified place.                                                                                                                                                                                                                                                                                                                                                                                                                                    | `NUMERIC`, `DOUBLE PRECISION` |
| `<digit>` | (Optional) You can specify a second parameter to define the position of the digit to round up to, based on its distance from the decimal point. Positive numbers indicate digits after the decimal, while negative numbers refer to digits before. For example, `1` rounds up to the first digit after the decimal, and `-1` rounds up to the nearest ten. A value of `0` rounds up to the nearest whole number. The default is `0`, which means that rounding up happens at the whole number. | `INTEGER`                     |

## Return Type

| Input Type         | Output Type                                  |
| :----------------- | :------------------------------------------- |
| `NUMERIC`          | `NUMERIC` with same `precision` and `scale`. |
| `DOUBLE PRECISION` | `DOUBLE PRECISION`                           |

## Remarks

When the input is of type `NUMERIC`, `CEIL` throws an overflow error if the result of `CEIL` exceeds the defined precision and scale limits of the return data type.

The following code example calculates the nearest whole number larger than `99.99` and specifies that the output should contain a total of `4` digits, with only `2` digits reserved for the decimal part:

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT CEIL('99.99'::NUMERIC(4,2));
```

**Returns**

The previous code returns an `OVERFLOW ERROR` because `CEIL` returns `100.00`, which exceeds the `NUMERIC(4,2)` data type's limit of `2` digits before the decimal point, and `100` requires `3` digits.

## Examples

The following example returns the nearest whole number larger than `2.5549900`:

<QueryWindow
  content={{
"sql": "SELECT CEIL(2.5549900);",
"result": {
"data": [
  [
    3
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "4728e2d1-0d36-40b3-9328-d7a5189df310",
  "query_label": null,
  "request_id": "a48d6da2-d037-4328-8ad9-f7b10204a320"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.007994,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000253142,
  "time_to_execute": 9.5313e-05
}
}
}}
/>

The following example calculates the nearest whole number larger than `213.1549`, and returns a result of type `NUMERIC(20,4)`, which allows for a total of 20 digits, with 4 values allowed after the decimal point:

<QueryWindow
  content={{
"sql": "SELECT CEIL('213.1549'::NUMERIC(20,4));",
"result": {
"data": [
  [
    214.0
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "Decimal(20, 4)"
  }
],
"query": {
  "query_id": "873b8d9f-99e2-42a1-9a4f-cbbe41bebb8b",
  "query_label": null,
  "request_id": "ba2f506c-da24-40eb-847e-0a10bd11cbd4"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.006949,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000244866,
  "time_to_execute": 8.6494e-05
}
}
}}
/>

The following example rounds the number `2.5549900` up to the second decimal place.
It returns `2.56` because the second parameter 2 specifies rounding to the second digit after the decimal, which corresponds to the hundredths place.

<QueryWindow
  content={{
"sql": "SELECT CEIL(2.5549900, 2);",
"result": {
"data": [
  [
    2.56
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "d963a9c5-a663-43ff-8ce7-a0559130b335",
  "query_label": null,
  "request_id": "9baf1eb1-4ae2-4937-85aa-3aa0d19f26c8"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.006904,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000244485,
  "time_to_execute": 8.3618e-05
}
}
}}
/>

The following example calculates the nearest whole number greater than `1998` that is a multiple of `1000`.
It returns `2000` because the second parameter -3 specifies rounding to the third digit before the decimal point, which corresponds to the thousands place.

<QueryWindow
  content={{
"sql": "SELECT CEIL(1998, -3);",
"result": {
"data": [
  [
    2000
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "da09432c-db54-43ca-bbc7-69e43321935d",
  "query_label": null,
  "request_id": "86f5da32-dbf4-4d3f-832d-1bd32292175c"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.006489,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000241991,
  "time_to_execute": 8.6836e-05
}
}
}}
/>
