LOG() Function in SQL Server
Last Updated :
29 Sep, 2020
Improve
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.
SELECT LOG(4);Output :
1.3862943611198906Example-2 : It will Return the natural logarithm of 3 to a specified base 6.
SELECT LOG(3, 6);Output :
0.61314719276545848Example-3 : When the PI() function passing one of the arguments with specified base 5.
SELECT LOG(PI(), 5);Output :
0.71126066871266902Example-4 : When the argument passing as a expressions with specified base.
SELECT LOG(3 + 2, 5);Output :
1.0Example-5 : Both LOG and LOG10 having base 10.
SELECT LOG(1000, 10) 'LOG', LOG10(1000) 'LOG10';Output :
| LOG | LOG10 | |-------+--------| | 3 | 3 |