Available in versions: Dev (3.21) | Latest (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15

ANY_VALUE

Supported by ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The ANY_VALUE() aggregate function produces any random value from the group, non-deterministically

SELECT any_value(ID)
FROM BOOK
create.select(anyValue(BOOK.ID))
      .from(BOOK)

Producing (for example):

+-----------+
| any_value |
+-----------+
|         3 |
+-----------+

Dialect support

This example using jOOQ:

anyValue(BOOK.ID)

Translates to the following dialect specific expressions:

ASE, Access, Aurora Postgres, CockroachDB, DB2, Derby, Exasol, Firebird, HSQLDB, Hana, Informix, MariaDB, SQLDataWarehouse, SQLServer, SQLite, Sybase, Teradata, Vertica, YugabyteDB

min(BOOK.ID)

Aurora MySQL, BigQuery, Databricks, DuckDB, H2, MemSQL, MySQL, Oracle, Postgres, Redshift, Snowflake, Spanner

any_value(BOOK.ID)

ClickHouse

any(BOOK.ID)

Trino

arbitrary(BOOK.ID)
Generated with jOOQ 3.21. Support in older jOOQ versions may differ. 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