
jOOQ Masterclass
By :

In this section, grouping refers to the usage of GROUP BY
with functions, filtering refers to the usage of the FILTER
clause with functions, and distinctness refers to aggregate functions on distinct values.
As you already know, GROUP BY
is a SQL clause useful for arranging rows in groups via one (or more) column given as an argument. Rows that land in a group have matching values in the given columns/expressions. Typical use cases apply aggregate functions on groups of data produced by GROUP BY
.
Important Note
Especially when dealing with multiple dialects, it is correct to list all non-aggregated columns from the SELECT
clause in the GROUP BY
clause. This way, you avoid potentially indeterminate/random behavior and errors across dialects (some of them will not ask you to do this (for example, MySQL), while others will (for example, Oracle)).
jOOQ supports GROUP BY
in all dialects, therefore here is an example...