# LOG

Returns the logarithm of the given argument in the given 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: the base of the logarithm.
* number: the 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: April 4, 2023

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

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