PostgreSQL 17.5
LN(num)Parameters
- numnumeric | double precision
- Positive number
Return value
A number of the same type as num (double precision or numeric); an error for 0 and negative numbers
Examples
Logarithm of e and 10
PostgreSQL 17.5
SELECT LN(EXP(1)) AS ln_e,
LN(10) AS ln_10;Years to double a deposit at 7%
PostgreSQL 17.5
SELECT ROUND((LN(2) / LN(1.07))::numeric, 1) AS years_to_double;Details
The reverse function is EXP. A logarithm to another base is computed by LOG(base, num), the base-10 one by LOG10. In MySQL the natural logarithm is also returned by LOG with one argument.