public interface OrderedAggregateFunction<T>
An ordered-set aggregate function is an aggregate function with a mandatory
Oracle-specific WITHIN GROUP (ORDER BY ..)
clause. An example is
LISTAGG
:
The above function groups books by author and aggregates titles
into a concatenated string.
SELECT LISTAGG(TITLE, ', ')
WITHIN GROUP (ORDER BY TITLE)
FROM T_BOOK
GROUP BY AUTHOR_ID
Ordered-set aggregate functions can be further converted into window functions
using the OVER(PARTITION BY ..)
clause. For example:
SELECT LISTAGG(TITLE, ', ')
WITHIN GROUP (ORDER BY TITLE)
OVER (PARTITION BY AUTHOR_ID)
FROM T_BOOK
Modifier and Type | Method and Description |
---|---|
AggregateFilterStep<T> |
withinGroupOrderBy(Collection<? extends SortField<?>> fields)
Add an
WITHIN GROUP (ORDER BY ..) |
AggregateFilterStep<T> |
withinGroupOrderBy(Field<?>... fields)
Add an
WITHIN GROUP (ORDER BY ..) |
AggregateFilterStep<T> |
withinGroupOrderBy(SortField<?>... fields)
Add an
WITHIN GROUP (ORDER BY ..) |
@Support(value={CUBRID,DB2,H2,HSQLDB,MARIADB,MYSQL,ORACLE11G,ORACLE12C,POSTGRES,REDSHIFT,SYBASE}) AggregateFilterStep<T> withinGroupOrderBy(Field<?>... fields)
WITHIN GROUP (ORDER BY ..)
clause to the ordered
aggregate function@Support(value={CUBRID,DB2,H2,HSQLDB,MARIADB,MYSQL,ORACLE11G,ORACLE12C,POSTGRES,REDSHIFT,SYBASE}) AggregateFilterStep<T> withinGroupOrderBy(SortField<?>... fields)
WITHIN GROUP (ORDER BY ..)
clause to the ordered
aggregate functionCopyright © 2016. All Rights Reserved.