Skip to main content


Calculates the logarithm of a number to a specified base, which is a more general form of logarithmic function compared to LN, which uses base (e).

See also:


SELECT LOG(base, numeric_expression) FROM <multipartIdentifier>;


The base of the logarithm, a positive numeric expression other than 1.

A positive numeric expression for which the logarithm is to be calculated.

Return Value(s)

Returns the logarithm of the specified numeric value to the specified base.


Calculate the logarithm of 1000 with base 10

SELECT LOG(10, 1000) AS log_result;

This query returns 3, as (10^3 = 1000).

Calculate the logarithm of 16 with base 2

SELECT LOG(2, 16) AS log_result;

This query calculates the logarithm of 16 with base 2, resulting in 4, since (2^4 = 16).