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

# LOG

> Returns a logarithm in the specified base.

<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"}}
log(base, value)
```

## Arguments

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

## Returns

* Type: DOUBLE for DECIMAL or integer input; FLOAT when the input is evaluated as FLOAT
* Possible values: A floating-point logarithm; invalid mathematical domains produce NaN or infinity.
* NULL behavior: Returns NULL when an argument is NULL.

## Properties

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

* Approximation bound: No fixed maximum error is guaranteed.

## Usage notes

* Decimal perfect powers at scale zero may use exact integer logarithm detection before falling back to floating point.
* 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.
* Exact result: Floating-point computation can round the mathematical result.

## Examples

### Value and NULL input

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT log(CAST(2 AS DOUBLE), CAST(8 AS DOUBLE)) AS "value", log(CAST(NULL AS DOUBLE), CAST(8 AS DOUBLE)) AS null_value;
```

| value | null\_value |
| - | - |
| 3 | NULL |

### Change the base

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
SELECT log(CAST(10 AS DOUBLE), CAST(100 AS DOUBLE)) AS base_10, log(CAST(2 AS DOUBLE), CAST(0.5 AS DOUBLE)) AS base_2;
```

| base\_10 | base\_2 |
| - | - |
| 2 | -1 |

## Limitations

* Supply two numeric arguments. The one-argument base-10 form is not supported. An input evaluated as FLOAT returns FLOAT even when query tools report DOUBLE.


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