The LN function in Oracle SQL is a mathematical function that returns the natural logarithm of a number. The natural logarithm is the logarithm to the base e, where e is a mathematical constant approximately equal to 2.71828183.
This function is the inverse of EXP (which raises e to a power). It's commonly used in scientific, statistical, and financial calculations.
What is the LN Function in Oracle?
The LN function answers the question: "To what power must e be raised to get the number n?"
nmust be greater than 0. You cannot take the natural logarithm of zero or a negative number.LN(1)returns0(becausee^0 = 1).LN(e)(orLN(EXP(1))) returns1(becausee^1 = e).
LN Function Syntax
The syntax for LN is very simple:
LN(n)
Let's break that down:
n: The number for which you want to find the natural logarithm. It must be a positive number.
Oracle LN Function Examples
Here are two practical examples of how to use LN.
Example 1: Finding the Natural Log of 1
This example shows a fundamental property of logarithms: the log of 1 is always 0.
Query:
SELECT
LN(1) AS "Log_of_1"
FROM DUAL;
Result:
Log_of_1
----------
0
Example 2: Finding the Natural Log of a Number
This example calculates the natural logarithm of 95.
Query:
SELECT
LN(95) AS "Natural_Log_of_95"
FROM DUAL;
Result:
Natural_Log_of_95
-----------------
4.55387689
