> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback:

POST https://docs.firebolt.io/feedback

```json
{
  "path": "/reference-sql/functions-reference/numeric/log",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.

</AgentInstructions>

> Reference material for LOG function

# LOG

export const QueryWindow = ({content}) => {
  const {sql, result} = content;
  const [inited, setInited] = useState(false);
  const buttonRef = useRef(null);
  useEffect(() => {
    if (!inited && buttonRef.current) {
      runQuery(buttonRef.current, true);
      setInited(true);
    }
  }, []);
  return <div className="query-window">
      <div className="query-toolbar">
        <button className="run-button" onClick={ev => runQuery(ev.target)} ref={buttonRef}>Run Query</button>
        <span className="window-title">Interactive SQL Playground 🔥</span>
      </div>
      <div className="query-content">
        <pre><code className="firebolt-sql language-sql" contentEditable="true" spellCheck="false" data-original-query={sql}>{sql}</code></pre>
        <script type="application/json" className="fallback-result" style={{
    display: "none"
  }}>{JSON.stringify(result)}</script>
        <div className="server-unavailable-banner query-window-hidden">
          The Firebolt playground server is currently unavailable. Using precomputed query results.
        </div>
        <div className="query-results"></div>
      </div>
    </div>;
};

Returns the common (base 10) logarithm of a numerical expression, or the logarithm to an arbitrary base if specified as the first argument.
The value for which `log` is computed needs to be larger than 0, otherwise an error is returned.
If a base is provided, it also needs to be larger than 0 and not equal to 1.
You can use the function [LN](/reference-sql/functions-reference/numeric/ln) to compute the natural logarithm (base e).

**Alias:** `LOG10` (does not support a custom `base` argument)

## Syntax

```sql theme={"theme":{"light":"github-light","dark":"github-dark"}}
LOG([<base>,] <value>);
```

## Parameters

| Parameter | Description                                                   | Supported input types |
| :-------- | :------------------------------------------------------------ | :-------------------- |
| `<base>`  | Optional. The base for the logarithm. The default base is 10. | `DOUBLE PRECISION`    |
| `<value>` | The value for which to compute the logarithm.                 | `DOUBLE PRECISION`    |

## Return Type

`DOUBLE PRECISION`

## Example

The following example returns the logarithm of 64.0 to base 2:

<QueryWindow
  content={{
"sql": "SELECT LOG(2, 64.0);",
"result": {
"data": [
  [
    6
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "5d5bf58b-4161-4047-903f-015e60f06f71",
  "query_label": null,
  "request_id": "75b06af6-d1f1-4ccb-bcdb-f34caa8faaa1"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.007124,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000248475,
  "time_to_execute": 9.1005e-05
}
}
}}
/>

The following example returns the logarithm of 100.0 to the default base 10:

<QueryWindow
  content={{
"sql": "SELECT LOG(100.0), LOG10(100.0);",
"result": {
"data": [
  [
    2,
    2
  ]
],
"meta": [
  {
    "name": "?column?",
    "type": "double"
  },
  {
    "name": "?column?",
    "type": "double"
  }
],
"query": {
  "query_id": "026387a9-c2c2-4384-af56-037de4b14d1b",
  "query_label": null,
  "request_id": "5079df80-0b27-4339-aaed-1253dc92dce4"
},
"rows": 1,
"statistics": {
  "bytes_read": 1,
  "elapsed": 0.007109,
  "rows_read": 1,
  "scanned_bytes_cache": 0,
  "scanned_bytes_storage": 0,
  "time_before_execution": 0.000248564,
  "time_to_execute": 8.7073e-05
}
}
}}
/>

The logarithm can only be computed for values that are larger than 0. All the following functions return an error:

<QueryWindow
  content={{
"sql": "SELECT LOG(0.0);\n-- SELECT LOG(-1.0);\n-- SELECT LOG('-Inf');",
"result": {
"errors": [
  {
    "description": "Line 1, Column 8: Cannot take the logarithm of 0. The argument needs to be larger than 0.\nSELECT LOG(0.0);\n       ^",
    "location": {
      "failing_line": 1,
      "start_offset": 8
    }
  }
],
"query": {
  "query_id": "5cca4717-f64f-4a09-8a03-691407f3f238",
  "query_label": null,
  "request_id": "6ec27123-bb7d-4f38-96ec-760665b2119a"
},
"statistics": {
  "elapsed": 0.000697768
}
}
}}
/>

When a base is provided, it needs to be positive and not equal to zero. All the following functions return an error:

<QueryWindow
  content={{
"sql": "SELECT LOG(0.0, 10.0);\n-- SELECT LOG(-1.0, 10.0);\n-- SELECT LOG(1.0, 10.0);\n-- SELECT LOG('-Inf', 10.0);",
"result": {
"errors": [
  {
    "description": "Line 1, Column 8: Cannot take the logarithm of base 0. The base needs to be larger than 0 but not 1.\nSELECT LOG(0.0, 10.0);\n       ^",
    "location": {
      "failing_line": 1,
      "start_offset": 8
    }
  }
],
"query": {
  "query_id": "04d6a002-cb23-4dfc-8b16-2984c4830d47",
  "query_label": null,
  "request_id": "37887ba0-34ca-465e-a130-337d9579a270"
},
"statistics": {
  "elapsed": 0.000655348
}
}
}}
/>
