Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

log
sql
math
communitycreator

# What is LOG() in SQL? Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The LOG() function returns the logarithm of a number to the specific base.

Figure 1 shows the mathematical representation of the LOG() function:

Figure 1: Mathematical representation of the LOG() function

## Syntax

LOG(base, number)


## Parameter

This function requires two parameters:

• The base of the logarithma number (which must be greater than one) is an optional parameter.
• A number whose logarithm is to be calculated, it must be greater than zero.

## Return Value

LOG() returns the logarithm of a number to the specific base sent as a parameter.

If the base is omitted, then the LOG() function calculates the natural logarithm of a number, which is the same as the LOG() function with a base of the mathematical constant e.

If the base is less than one, or the number is less than zero, the function will return NULL.

## Example

/*example showing how to use LOG(base, number)*/

-- positive number without base
select LOG(10);

-- positive number with base
select LOG(3,3);

-- zero number with base
select LOG(2,0);

-- positive number with base 0
select LOG(0,2);


RELATED TAGS

log
sql
math
communitycreator

CONTRIBUTOR Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Learn in-demand tech skills in half the time 