LN
LN is a mathematical SQL function that calculates the natural logarithm of a given number.
Example
SELECT LN(2);
Output
0.6931471805599453
Explanation
In the given SQL query, the LN()
function is used to compute the natural logarithm of 2. The natural logarithm of a number is the logarithm to the base e, where e is an irrational and transcendental number approximately equal to 2.718281828. The LN(2)
function returns the natural logarithm of 2, approximately equal to 0.6931471805599453.
Example
SELECT LN(10);
Output
2.30258509299405
Explanation
The LN()
function in PostgreSQL has returned the natural logarithm of 10, which equates to approximately 2.30258509299405. It accepts a numeric argument, evaluating the natural logarithm with the base “e” (about 2.71828).
Example
SELECT LN(2.71828) AS Logarithm_Value;
Output
1.999999327347282
Explanation
In the given example, the LN
function is used to calculate the natural logarithm of the number 2.71828. The result is approximately 1.999999327347282. LN is a mathematical function available in SQL Server that returns the natural logarithm of a specified float expression.
Example
SELECT LN(1) AS natural_logarithm FROM dual;
Output
NATURAL_LOGARITHM------------------0
Explanation
The SQL code selects the natural logarithm (LN) of 1 from a sole row provided by “dual”. In mathematical terms, the natural logarithm of 1 is always 0, which is reflected in the output.