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

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:

-- ACCESS, ASE
(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)

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

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

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

(These are currently generated with jOOQ 3.19, see #10141), or translate your own on our website

Feedback

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

The jOOQ Logo