Product Solutions Support
Try MemSQL

LOG

Returns the logarithm of the given argument in the given base. If only one argument is given, this function returns the “natural” logarithm to base e.

LOG ( base, number )
LOG ( number )
LN ( number )

Arguments

Info

log(n) is an alias for ln(n).

log(b, n) is equivalent to ln(n) / ln(b).

Return Type

Float or double. If number is less than or equal to 0, or if base is non-positive or 1, returns NULL.

Examples

memsql> select log(2, 16);
+------------+
| log(2, 16) |
+------------+
|          4 |
+------------+

memsql> select log(2, 1234);
+-------------------+
| log(2, 1234)      |
+-------------------+
| 10.26912667914942 |
+-------------------+

memsql> select log(1234);
+--------------------+
| log(1234)          |
+--------------------+
| 7.1180162044653335 |
+--------------------+

memsql> select ln(1234);
+--------------------+
| ln(1234)           |
+--------------------+
| 7.1180162044653335 |
+--------------------+

memsql> select log(10, 1000), ln(1000) / ln(10);
+--------------------+--------------------+
| log(10, 1000)      | ln(1000) / ln(10)  |
+--------------------+--------------------+
| 2.9999999999999996 | 2.9999999999999996 |
+--------------------+--------------------+

memsql> select log(-9);
+---------+
| log(-9) |
+---------+
|    NULL |
+---------+
Was this article useful?