Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

LOG

Example

Calculate and return the natural logarithm of 2.

SELECT LOG(2);

Definition and Usage

The LOG() function computes the natural logarithm of a given number or can compute the logarithm of a number to a specified base.

Starting from SQL Server 2012, you can adjust the base of the logarithm using an optional parameter.

Note: Consider exploring the EXP() function for exponential calculations.

Syntax

LOG(number, base) — Syntax for SQL Server

OR:

LOG(number) — Syntax for Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse

Parameter Values

Parameter

Description

number

Required: The input number for which the natural logarithm is calculated, must be greater than 0.

base

Optional: The base with which the natural logarithm is computed, must be greater than 1.

Technical Details

Works in:

SQL Server (beginning from 2008), Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse

More Examples

Example

Calculate and return the natural logarithm of 2 with a specified base of 4.

SELECT LOG(24);