Returns natural logarithm of X. We cap add one more argument to specify Base.
SELECT LOG( X )
X is the number and B is the base. The output is log value of X with base B.
SELECT LOG( B,X )
Using ROUND() with LOG()
If Base is less than or equal to 1 then NULL is returned, similarly if X is less than or equal to 0 then NULL is returned.
SELECT ROUND(LOG(2),2);// Ouput is 0.69
SELECT ROUND(LOG(-2),2); // Ouput is NULL
SELECT ROUND(LOG(6,3),2); // Output is 0.61
SELECT LOG( 6, -0.1 ); Output is NULL
SELECT LOG( -6, 2 ); // Output is NULL
SELECT LOG( 6, 0.1 ) // Output is -1.28509720893847
| ▼ More on Math functions in SQL|