LOG
The LOG() function returns the base-10 logarithm or logarithm of the specified base of a given number.
The following illustrates the syntax of the LOG() function:
Where:
- 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.
Let's explore some examples of the LOG() function.
In this case, the LOG() function calculates the base-10 logarithm of a specified number.
You will get the output below:
In this example, the LOG() function is applied to negative numbers.
Any input of negative values will give you a NaN result.
The LOG() function will return NULL if the argument is NULL.
You will get a null result when an argument passed is null.
In this example, the LOG() takes zero as an argument.
You will get the output below:
In this case, the LOG() function calculates the logarithm of a specified number.
You will get the output below:
Consider a database table called data with the following records:
Use the LOG() function to calculate the logarithm of column x (as a base) and column y (as a number):
You will get the result as shown below: