Skip to main content

Categories: Math

LOG

Returns the logarithm of the input. If no base is specified, returns the natural logarithm (base e). Returns NULL if any input is NULL.

Syntax​

LOG([base_expression float], expression float) → double​

  • base_expression (optional): The base to use.
  • expression: The value for which you want to calculate the log.

Examples

LOG example
SELECT LOG(20.5, 1.5)
-- 0.1342410830900514

LOG([base_expression double], expression double) → double​

  • base_expression (optional): The base to use.
  • expression: The value for which you want to calculate the log.

Examples

LOG example
SELECT LOG(20.5, 1.5)
-- 0.1342410830900514
Return NULL for a NULL base
SELECT LOG(NULL, 1.5)
-- null
Return NULL for a NULL expression
SELECT LOG(20.5, NULL)
-- null

LOG(expression int64) → double​

  • expression: The value for which you want to calculate the log.

Examples

LOG example
SELECT LOG(10)
-- 2.302585092994046

LOG([base_expression int64], expression int64) → double​

  • base_expression (optional): The base to use.
  • expression: The value for which you want to calculate the log.

Examples

LOG example
SELECT LOG(10, 2)
-- 0.30102999566398114

LOG(expression int32) → double​

  • expression: The value for which you want to calculate the log.

Examples

LOG example
SELECT LOG(10)
-- 2.302585092994046
Calculate the natural logarithm of 100
SELECT LOG(100)
-- 4.605170185988092

LOG([base_expression int32], expression int32) → double​

  • base_expression (optional): The base to use.
  • expression: The value for which you want to calculate the log.

Examples

LOG example
SELECT LOG(10, 2)
-- 0.30102999566398114
Calculate the base 10 logarithm of 100
SELECT LOG(10, 100)
-- 2.0
Calculate the base 2 logarithm of 8
SELECT LOG(2, 8)
-- 3.0

LOG(expression float) → double​

  • expression: The value for which you want to calculate the log.

Examples

LOG example
SELECT LOG(12.5)
-- 2.5257286443082556

LOG(expression double) → double​

  • expression: The value for which you want to calculate the log.

Examples

LOG example
SELECT LOG(12.5)
-- 2.5257286443082556
Return NULL for a NULL input
SELECT LOG(NULL)
-- null

Usage Notes​

If base_expression is 1. If base_expression expression is less than 0, NaN will be returned. If the expression input is 0, -Infinity is returned. If the expression input is less than 0, NaN will be returned.