New versions: Dev (3.15) | Latest (3.14) | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | Old versions: 3.7 | 3.6 | 3.5 | 3.4 | 3.3

LN

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The LOG() function calculates the logarithm of a numeric value, given a base.

SELECT log(8, 2);
create.select(log(8, 2)).fetch();

The result being

+-----+          
| log |
+-----+
|   3 |
+-----+

Dialect support

This example using jOOQ:

log(8, 2)

Translates to the following dialect specific expressions:

-- ACCESS, ASE
(log(8) / log(2))

-- AURORA_MYSQL, AURORA_POSTGRES, CUBRID, FIREBIRD, H2, HANA, MARIADB, MEMSQL, MYSQL, ORACLE, POSTGRES, REDSHIFT, VERTICA
log(2, 8)

-- COCKROACHDB
(ln(CAST(8 AS numeric)) / ln(CAST(2 AS numeric)))

-- DB2, DERBY, HSQLDB, INGRES, SYBASE, TERADATA
(ln(8) / ln(2))

-- INFORMIX
(logn(8) / logn(2))

-- SQLDATAWAREHOUSE, SQLSERVER
log(8, 2)

-- SQLITE
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.15, see #10141)

The jOOQ Logo