Oracle LOG() Function
Oracle LOG() is a built-in function that returns the logarithm of a given value, taking a given value as the base.
Oracle LOG() syntax
Here is the syntax for the Oracle LOG() function:
LOG(base, num)
Parameters
base-
Required. Base number. It should be greater than 0. It can be any numeric data type or any non-numeric data type that can be implicitly converted to a numeric data type.
num-
Required. A number whose logarithm needs to be obtained. It can be any numeric data type or any non-numeric data type that can be implicitly converted to a numeric data type.
Return Value
The Oracle LOG() function returns the logarithm of num, base base.
This function returns BINARY_DOUBLE if any parameter is BINARY_FLOAT or BINARY_DOUBLE. Otherwise this function returns NUMBER.
If any parameter is NULL, LOG() will return NULL.
Oracle LOG() Examples
Here are some examples that demonstrate the usage of the Oracle LOG() function.
Basic Usage
The following statement computes the logarithm of 100, base 10:
SELECT
LOG(10, 100)
FROM dual;
Output:
LOG(10,100)
______________
2NULL Parameters
If any parameter is NULL, LOG() will return NULL.
SET NULL 'NULL';
SELECT
LOG(1, NULL),
LOG(NULL, 1),
LOG(NULL, NULL)
FROM dual;
Output:
LOG(1,NULL) LOG(NULL,1) LOG(NULL,NULL)
______________ ______________ _________________
NULL NULL NULLIn this example, we use the statement SET NULL 'NULL'; to display NULL values as the string 'NULL'.
Conclusion
Oracle LOG() is a built-in function that returns the logarithm of a given value, taking the given value as the base.