|The jOOQ User Manual : SQL building : Column expressions : Aggregate functions : Ordering WITHIN GROUP||previous : next|
Ordering WITHIN GROUP
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Some aggregate functions allow for ordering their inputs to produce an ordered output. These aggregate functions allow for specifying a mandatory
WITHIN GROUP (ORDER BY ..) clause after the function.
Standard SQL talks about "ordered set aggregate functions" which come in three flavours
- Hypothetical set functions: Functions that check for the position of a hypothetical value inside of an ordered set. These include RANK, DENSE_RANK, PERCENT_RANK, CUME_DIST.
LISTAGG, which is inconsistently using the
WITHIN GROUPsyntax, as it is used to order the output of the function, and isn't mandatory in all dialects.