SQL LOG Function
The SQL LOG function allows us to operate mathematical logarithmic calculation. Here is the syntax:
LOG(<base>, <numeric_expression>)
Here is the example query :
SELECT LOG(2,4) as log_base_2_of_4,
LOG(10,100) as lg_of_100
And the output is :
log_base_2_of_4 lg_of_100
--------------- ---------
2 2
Beside SQL LOG() function, we can use other specified logarit functions as folows:
LN(<numeric_expression>) LOG2(<numeric_expression>) LOG10(<numeric_expression>)
Here is an example query and output:
SELECT LOG2(4) as log_base_2_of_4,
LOG10(1000) as log_base_10_of_1000,
LN(1) as ln_of_10
log_base_2_of_4 log_base_10_of_1000 ln_of_10
--------------- ------------------- --------
2 3 0