LOG function
Returns logarithm of a number.
If you're using this function to calculate the base 10 logarithm, you can also use DLOG10 function.
Syntax
LOG([base, ]argument)
Parameters
- base
-
(Optional) The base of the logarithm function. This number must be positive and can't equal
1
. If this parameter is omitted, Amazon Redshift computes the base 10 logarithm of the argument. - argument
-
The argument of the logarithm function. This number must be positive. If the argument value is
1
, the function returns0
.
Return type
The LOG function returns a DOUBLE PRECISION
number.
Examples
To find the base 2 logarithm of 100, use the following example.
SELECT LOG(2, 100);
+-------------------+ | log | +-------------------+ | 6.643856189774725 | +-------------------+
To find the base 10 logarithm of 100, use the following example. Note that if you omit the base parameter, Amazon Redshift assumes a base of 10.
SELECT LOG(100);
+-----+ | log | +-----+ | 2 | +-----+