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

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