Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10

LOG

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:

ASE, Access

(log(8) / log(2))

Aurora MySQL, Aurora Postgres, Exasol, Firebird, H2, Hana, MariaDB, MemSQL, MySQL, Oracle, Postgres, Redshift, Snowflake, Trino, Vertica, YugabyteDB

log(2, 8)

BigQuery, SQLDataWarehouse, SQLServer

log(8, 2)

ClickHouse, DB2, Derby, DuckDB, HSQLDB, SQLite, Sybase, Teradata

(ln(8) / ln(2))

CockroachDB

(ln(CAST(8 AS decimal)) / ln(CAST(2 AS decimal)))

Informix

(logn(8) / logn(2))
Generated with jOOQ 3.20. Translate your own SQL on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo