<<<<<<< HEAD ln | H2 | SQLDoc
Skip to main content

ln

1. LN Function

======= ln | H2 Function | SQLDoc

ln

1. LN Function

>>>>>>> 9d19b1c8cb744c8e86d5c15b74d8b5f719ad62be

The LN function in H2 database is used to calculate the natural logarithm of a given number.

2. Syntax

The syntax for the LN function in H2 database is as follows:

LN(number)

Arguments

  • number: The number for which the natural logarithm needs to be calculated. It should be a positive numeric value.

Return

  • The LN function returns the natural logarithm of the given number.

3. Notes

  • The LN function in H2 database calculates the natural logarithm, which is the logarithm to the base e (Euler's number, approximately 2.718).
  • If the input number is not a positive numeric value, the LN function will return NULL.
  • Be cautious when using the LN function with extremely large or small numbers, as it may result in overflow or underflow errors.

4. Examples

Here are a few examples demonstrating the usage of the LN function in H2 database:

Example 1 - Calculating the natural logarithm of 2:

SELECT LN(2) AS natural_log;

Output:

natural_log
-----------
0.6931471805599453

Example 2 - Calculating the natural logarithm of numbers stored in a column:

CREATE TABLE numbers (
id INT PRIMARY KEY,
value DOUBLE
);

INSERT INTO numbers VALUES (1, 1), (2, 2.5), (3, 10);

SELECT id, value, LN(value) AS natural_log
FROM numbers;

Output:

id | value |   natural_log
---+-------+---------------
1 | 1 | 0.0
2 | 2.5 | 0.916290731874155
3 | 10 | 2.302585092994046
  • log - Calculate logarithm to a specified base (not necessarily the natural logarithm).