# abs

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: abs
latest-operator-version: v26.1.4
latest-console-tag: v3.7.3
latest-connect-version: 4.93.0
latest-redpanda-tag: v26.1.9
docname: sql/sql-functions/math-functions/abs
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-functions/math-functions/abs.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-functions/math-functions/abs.adoc
description: The `abs()` function returns an absolute number (for example, the positive value of a number).
page-topic-type: reference
page-git-created-date: "2026-05-26"
page-git-modified-date: "2026-05-26"
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-functions/math-functions/abs.md -->

The `abs()` function returns an absolute number (for example, the positive value of a number). The data type of the returned value will depend on the data type of the value passed to the `abs()` function.

## [](#syntax)Syntax

Here’s the syntax for the \`abs()\`function:

```sql
ABS(x)
```

The `abs()` function requires one argument:

-   `x`: An expression that evaluates to a number.


> 📝 **NOTE**
>
> The **`abs()`** function will return the negation of the negative numbers.

## [](#examples)Examples

### [](#absolute-value-of-a-negative-number)Absolute value of a negative number

This example demonstrates how to use the `abs()` function to obtain the absolute value of a negative number:

```sql
SELECT ABS(-10.25);
```

This returns an absolute value of the passed argument:

```sql
+--------+
| f      |
+--------+
| 10.25  |
+--------+
```

### [](#abs-function-with-an-expression)`abs()` function with an expression

This example demonstrates how to use the `abs()` function with an expression to obtain the absolute value of the result:

```sql
SELECT ABS( 100 - 250);
```

The result of this statement is **\-150**. However, the output is **150**, as 150 is the positive version of -150.

```sql
+------+
| f    |
+------+
| 150  |
+------+
```

### [](#use-the-abs-function-with-a-table)Use the `abs()` function with a table

This example demonstrates how to use the `abs()` function with a table to obtain the absolute values of all numbers in a specific column:

1.  First, create a table named absTable containing an **_initialValue_** column with some positive and negative values:

    ```sql
    CREATE TABLE absTable(initialValue float);

    INSERT INTO absTable(initialValue)
    VALUES
    (550),
    (-210),
    (72.12),
    (-87.93),
    (-0.0);
    ```

2.  Next, use this query to find the absolute value of all numbers:

    ```sql
    SELECT initialValue, ABS(initialValue) AS absoluteValue
    FROM absTable;
    ```

3.  This query retrieves all values in the **“initialValue”** column and their absolute values in the **“absoluteValue”** column. The output will look something like this:

    ```sql
    +---------------+----------------+
    | initialValue  | absoluteValue  |
    +---------------+----------------+
    | 550           | 550            |
    | -210          | 210            |
    | 72.12         | 72.12          |
    | -87.93        | 87.93          |
    | -0            | 0              |
    +---------------+----------------+
    ```