SQL Tutorial SQL Advanced SQL Database SQL References

Oracle LN() Function



The Oracle (PL/SQL) LN() function returns the natural logarithm of a given number. In special cases it returns the following:

  • If the number is less than or equal to 0, then an error is returned.

Syntax

LN(number)

Parameters

number Required. Specify the number. Must be greater than 0.

Return Value

Returns the natural logarithm of the given number.

Example 1:

The example below shows the usage of LN() function.

LN(1)
Result: 0

LN(1.5)
Result: .4054651081081643819780131154643491365787

LN(5)
Result: 1.60943791243410037460075933322618763953

Example 2:

Consider a database table called Sample with the following records:

Datax
Data 10.5
Data 21
Data 35
Data 410
Data 550

The statement given below can be used to calculate the natural logarithm of values of column x.

SELECT Sample.*, 
LN(x) AS LN_Value 
FROM Sample;

This will produce the result as shown below:

DataxLN_Value
Data 10.5-.6931471805599453094172321214581765680774
Data 210
Data 351.60943791243410037460075933322618763953
Data 4102.3025850929940456840179914546843642076
Data 5503.91202300542814605861875078791055184712

❮ Oracle Functions