---
title: "LOG"
description: "The LOG SQL function gets the natural logarithm of a number in a specified base."
language: en
source_language: en
translation_state: complete
canonical: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/log
original: https://documentation.invantive.eu/en/docs/invantive-universalsql/grammar/sql-functions/log
updated: 2026-08-09T00:00:00Z
license: https://documentation.invantive.eu/en/
---

## Syntax
```mermaid
%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> LOG[LOG]:::quoted
    LOG --> End((END))
```

## Purpose
The `LOG` SQL function gets the natural logarithm of a number in a specified base.

See also [[LN]] and [[EXP]].

Parameters:
- Input (`decimal`): a number to get the logarithm from.
- Base (optional, `decimal`): the base to get the logarithm from. Defaults to the number e.

Returns: the natural logarithm of the input in the specified base.

## Examples
The following example retrieves the logarithm of 8 in base 2:
```sql
select log(8, 2)

-------------------
3
```
The following example retrieves the logarithm of 100 in base 10:
```sql
select log(100, 10)

-------------------
2
```
The following example retrieves the natural logarithm of 1:
```sql
select log(1)

-------------------
0
```