Oracle LN Function: A Simple Guide

The LN function in Oracle SQL is a mathematical function that returns the natural logarithm of a number. The natural logarithm is the logarithm to the base e, where e is a mathematical constant approximately equal to 2.71828183.

This function is the inverse of EXP (which raises e to a power). It's commonly used in scientific, statistical, and financial calculations.

What is the LN Function in Oracle?

The LN function answers the question: "To what power must e be raised to get the number n?"

  • n must be greater than 0. You cannot take the natural logarithm of zero or a negative number.
  • LN(1) returns 0 (because e^0 = 1).
  • LN(e) (or LN(EXP(1))) returns 1 (because e^1 = e).

LN Function Syntax

The syntax for LN is very simple:

LN(n)

Let's break that down:

  • n: The number for which you want to find the natural logarithm. It must be a positive number.

Oracle LN Function Examples

Here are two practical examples of how to use LN.

Example 1: Finding the Natural Log of 1

This example shows a fundamental property of logarithms: the log of 1 is always 0.

Query:

SELECT 
  LN(1) AS "Log_of_1"
FROM DUAL;

Result:

  Log_of_1
----------
         0

Example 2: Finding the Natural Log of a Number

This example calculates the natural logarithm of 95.

Query:

SELECT 
  LN(95) AS "Natural_Log_of_95"
FROM DUAL;

Result:

Natural_Log_of_95
-----------------
       4.55387689
Vinish Kapoor
Vinish Kapoor

Vinish Kapoor is a seasoned software development professional and a fervent enthusiast of artificial intelligence (AI). His impressive career spans over 25+ years, marked by a relentless pursuit of innovation and excellence in the field of information technology. As an Oracle ACE, Vinish has distinguished himself as a leading expert in Oracle technologies, a title awarded to individuals who have demonstrated their deep commitment, leadership, and expertise in the Oracle community.

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments