Skip to content
Related Articles

Related Articles

Improve Article
LOG() Function in SQL Server
  • Last Updated : 29 Sep, 2020

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

Syntax :

LOG(number, base)

Parameter :
LOG() function accepts two-parameters as mentioned above and described below.

  • number –
    This parameter hold a number which is greater than 0.
  • base –
    It is the optional integer argument that sets the base for the logarithm.

Returns –
It returns the logarithm of the specified number with specified base.

Example-1 :
Return the natural logarithm of 4.



SELECT LOG(4);

Output :

1.3862943611198906

Example-2 :
It will Return the natural logarithm of 3 to a specified base 6.

SELECT LOG(3, 6);

Output :

0.61314719276545848

Example-3 :
When the PI() function passing one of the arguments with specified base 5.

SELECT LOG(PI(), 5);

Output :

0.71126066871266902

Example-4 :
When the argument passing as a expressions with specified base.

SELECT LOG(3 + 2, 5);

Output :

1.0

Example-5 :
Both LOG and LOG10 having base 10.

SELECT LOG(1000, 10) 'LOG',
LOG10(1000) 'LOG10';

Output :

| LOG  | LOG10   |
|-------+--------|
| 3    |  3      |
My Personal Notes arrow_drop_up
Recommended Articles
Page :