# LOG

The `LOG()` function returns the logarithm of the given argument, optionally in the specified base.

If only one argument is given, this function returns the *natural* logarithm to base `e`.

## Syntax

```sql
LOG ( base, number )
LOG ( number )

```

## Arguments

* `base`: Base of the logarithm.
* `number`: Number to take the logarithm of.

> **📝 Note**: `LOG(n)` is an alias for `LN(n)`.

`LOG(b, n)` is equivalent to `LN(n) / LN(b)`.

## Return Type

Float or double. If number is less than or equal to 0, or if base is non-positive or 1, returns `NULL`.

## Examples

```sql
SELECT LOG(2, 16);

```

```output

+------------+
| LOG(2, 16) |
+------------+
|          4 |
+------------+

```

```sql
SELECT LOG(2, 1234);

```

```output

+-------------------+
| LOG(2, 1234)      |
+-------------------+
| 10.26912667914942 |
+-------------------+
```

```sql
SELECT LOG(1234);

```

```output

+--------------------+
| LOG(1234)          |
+--------------------+
| 7.1180162044653335 |
+--------------------+
```

```sql
SELECT LN(1234);

```

```output

+--------------------+
| LN(1234)           |
+--------------------+
| 7.1180162044653335 |
+--------------------+
```

```sql
SELECT LOG(10, 1000), LN(1000) / LN(10);

```

```output

+--------------------+--------------------+
| LOG(10, 1000)      | LN(1000) / LN(10)  |
+--------------------+--------------------+
| 2.9999999999999996 | 2.9999999999999996 |
+--------------------+--------------------+
```

```sql
SELECT LOG(-9);

```

```output

+---------+
| LOG(-9) |
+---------+
|    NULL |
+---------+
```

***

Modified at: June 26, 2026

Source: [/cloud/reference/sql-reference/numeric-functions/log/](https://docs.singlestore.com/cloud/reference/sql-reference/numeric-functions/log/)

(An index of the documentation is available at /llms.txt)
