SQLite log() Function
The SQLite log()
function returns the logarithm of the base (10 default) specified by the parameter.
Syntax
Here is the syntax of the SQLite log()
function:
log(numeric_value)
log(base, numeric_value)
log(10, numeric_value)
is equivalent to log10(numeric_value)
.
Parameters
base
-
Required. base.
numeric_value
-
Required. A number whose logarithm needs to be obtained.
Return value
The SQLite log()
function will returns values as following:
- The
log()
function returns the base 10 logarithm of the specified numbernumeric_value
. - The
log()
function returns the basebase
logarithm of the specified numbernumeric_value
.
The SQLite log()
function will return NULL
if any parameter is NULL
.
The SQLite log()
function will return NULL
if the parameter is zero.
The SQLite log()
function will return NULL
if the parameter is negative.
The SQLite log()
function will return NULL
if the parameter is not numeric.
Examples
This example shows the basic usage of the SQLite log()
function:
SELECT
log(2, 3),
log(10, 4);
log(2, 3) = 1.58496250072116
log(10, 4) = 0.602059991327962
log(10, numeric_value)
is equivalent to log10(numeric_value)
. E.g:
SELECT
log(10, 4),
log10(4);
log(10, 4) = 0.602059991327962
log10(4) = 0.602059991327962