New versions: Dev (3.16) | Latest (3.15)

ANY_VALUE

Applies to ✅ 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:

-- ACCESS, ASE, AURORA_POSTGRES, COCKROACHDB, DB2, DERBY, EXASOL, FIREBIRD, H2, HANA, HSQLDB, INFORMIX, MARIADB, POSTGRES, 
-- SQLDATAWAREHOUSE, SQLITE, SQLSERVER, SYBASE, TERADATA, VERTICA, YUGABYTE
min(BOOK.ID)

-- AURORA_MYSQL, BIGQUERY, MEMSQL, MYSQL, ORACLE, REDSHIFT, SNOWFLAKE
any_value(BOOK.ID)

(These are currently generated with jOOQ 3.16, 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