|previous : next|
This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
GROUP BY column index
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
To work against some of SQL's verbosity, some SQL dialects support grouping by column index (starting from 1):
It is not recommended to use this feature in jOOQ as indexes tend to shift without developers noticing. The feature is supported mainly so jOOQ's SQL parser can parse and translate it. If you want to avoid redundancy in jOOQ, better resort to using a dynamic SQL style.
This example using jOOQ:
Translates to the following dialect specific expressions:
-- ACCESS, ASE, BIGQUERY, DB2, DERBY, EXASOL, H2, HANA, HSQLDB, ORACLE, SQLDATAWAREHOUSE, SQLSERVER, SYBASE SELECT BOOK.AUTHOR_ID, count(*) FROM BOOK GROUP BY BOOK.AUTHOR_ID -- AURORA_MYSQL, AURORA_POSTGRES, COCKROACHDB, DUCKDB, FIREBIRD, INFORMIX, MARIADB, MEMSQL, MYSQL, POSTGRES, REDSHIFT, -- SNOWFLAKE, SQLITE, TERADATA, TRINO, VERTICA, YUGABYTEDB SELECT BOOK.AUTHOR_ID, count(*) FROM BOOK GROUP BY 1