LOG() Function in SQL Server

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

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.