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

This is experimental functionality, and as such subject to change. Use at your own risk!

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;

References to this page


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

The jOOQ Logo