Available in versions: Dev (3.21)

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.

COUNT(DISTINCT ..) with redundant args

Supported by ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

The COUNT(DISTINCT ..) aggregate function counts the number of distinct non-NULL argument expression evaluations in the group. If the argument, then the redundant arguments can be removed.

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

-- With Settings.transformPatternsCountDistinctMultipleRedundant active, this:
SELECT
  COUNT(DISTINCT a, a),
  COUNT(DISTINCT a, b, a);

-- ... is transformed into the equivalent expression:
SELECT
  COUNT(DISTINCT a),
  COUNT(DISTINCT a, b);

Feedback

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

The jOOQ Logo