Available in versions: Dev (3.20) | Latest (3.19) | 3.18

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.

Unnecessary GROUP BY expressions

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

When an ordinary grouping set expression is repeated in the GROUP BY clause (i.e. not ROLLUP, CUBE, or GROUPING SETS), then one of the expressions can be removed as it has no effect.

Using Settings.transformPatternsUnnecessaryGroupByExpressions, the following transformations can be achieved:

-- With Settings.transformPatternsUnnecessaryGroupByExpressions active, this:
SELECT a, b, count(*) FROM t GROUP BY a, b, a;

-- ... is transformed into the equivalent expression:
SELECT a, b, count(*) FROM t GROUP BY a, b;

Feedback

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

The jOOQ Logo