Name
LN
The LN function returns the natural logarithm of a number, which is the power to which you would need to raise the mathematical constant e (approximately 2.718281) in order to get the number in question as the result.
ANSI SQL Standard Syntax
LN( expression
)
MySQL, Oracle, and PostgreSQL
MySQL, Oracle, and PostgreSQL support the ANSI SQL syntax for the LN function. MySQL and PostgreSQL also support the use of LOG as a synonym for LN.
SQL Server
SQL Server calls its natural logarithm function LOG:
LOG( expression
)
Example
The following Oracle-based example shows the natural logarithm of a number closely approximating the mathematical constant known as e:
SELECT LN(2.718281) FROM dual;
LN(2.718281)
------------
.999999695
Use the EXP function to go in the other direction.
Get SQL in a Nutshell, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.