Overview
TheLOG()
function returns the base-10 logarithm or logarithm of the specified base of a given number.
Syntax
The following illustrates the syntax of theLOG()
function:
base
: The base number. It must be greater than 0 and not equal to 1.number
: The number whose logarithm you want to obtain. It must be a positive number and greater than 0.
Examples
Let’s explore some examples of theLOG()
function.
Case #1: Get base-10 logarithm
1. Basic Usage
In this case, theLOG()
function calculates the base-10 logarithm of a specified number.
2. Using Negative Value
In this example, theLOG()
function is applied to negative numbers.
NaN
result.
3. Using Null Value
TheLOG()
function will return NULL
if the argument is NULL
.
4. Using Zero Value
In this example, theLOG()
takes zero as an argument.
Case #2: Get Logarithm
1. Basic Usage
In this case, theLOG()
function calculates the logarithm of a specified number.
2. Using Table
Consider a database table called data with the following records:LOG()
function to calculate the logarithm of column x (as a base) and column *y *(as a number):