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

# ABS

> Returns the absolute value of a number.

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

Returns NULL when an argument is NULL.

## Syntax

### Scalar

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

## Arguments

| Name | Type | Required | Description |
| - | - | - | - |
| value | TINYINT, SMALLINT, INTEGER, BIGINT, FLOAT, DOUBLE or DECIMAL(p, s) | Yes | The number whose magnitude is returned. For DECIMAL(p, s), p is precision (total digits) and s is scale (digits after the decimal point). |

## Returns

* Type: Same SQL type as value
* Possible values: The nonnegative magnitude; NaN remains NaN.
* NULL behavior: Returns NULL when an argument is NULL.

## Properties

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

## Usage notes

* 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.
* A DECIMAL result keeps its precision and scale as described above. Depending on decimal settings, query tools may report DOUBLE instead; this does not convert the returned value.

## Examples

### Value and NULL input

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT abs(-5) AS "value", abs(CAST(NULL AS INT)) AS null_value;
```

| value | null\_value |
| - | - |
| 5 | NULL |

### Integer and decimal inputs

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
WITH sample AS (
  SELECT id, CASE WHEN id = 0 THEN CAST(-7 AS BIGINT) ELSE CAST(8 AS BIGINT) END AS i,
    CASE WHEN id = 0 THEN CAST(-7.25 AS DECIMAL(8,2)) ELSE CAST(8.50 AS DECIMAL(8,2)) END AS d
  FROM range(0, 2)
)
SELECT abs(i) AS integer_value, abs(d) AS decimal_value FROM sample ORDER BY id;
```

| integer\_value | decimal\_value |
| - | - |
| 7 | 7.25 |
| 8 | 8.50 |

## Limitations

* The minimum signed value of TINYINT, SMALLINT, INT or BIGINT cannot be made positive in the same type and raises an overflow error.
* ABS supports numeric inputs. INTERVAL input is not supported.


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