|previous : next|
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
(These are currently generated with jOOQ 3.19, see #10141), or translate your own on our website
Do you have any feedback about this page? We'd love to hear it!