- All Known Subinterfaces:
OptionallyOrderedAggregateFunction<T>
,QOM.CumeDistAgg
,QOM.DenseRankAgg
,QOM.MaxBy<T>
,QOM.MinBy<T>
,QOM.PercentileCont
,QOM.PercentileDisc
,QOM.PercentRankAgg
,QOM.RankAgg
public interface OrderedAggregateFunction<T>
An ordered-set aggregate function.
An ordered-set aggregate function is an aggregate function with a mandatory
Oracle-specific WITHIN GROUP (ORDER BY …)
clause. An example is
LISTAGG
:
SELECT LISTAGG(TITLE, ', ')
WITHIN GROUP (ORDER BY TITLE)
FROM T_BOOK
GROUP BY AUTHOR_ID
The above function groups books by author and aggregates titles
into a concatenated string.
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
- Author:
- Lukas Eder
-
Method Summary
Modifier and TypeMethodDescription@NotNull AggregateFilterStep
<T> orderBy
(Collection<? extends OrderField<?>> fields) Add anORDER BY …
clause to the ordered aggregate function.@NotNull AggregateFilterStep
<T> orderBy
(OrderField<?>... fields) Add anORDER BY …
clause to the ordered aggregate function.@NotNull AggregateFilterStep
<T> withinGroupOrderBy
(Collection<? extends OrderField<?>> fields) Add anWITHIN GROUP (ORDER BY …)
clause to the ordered aggregate function.@NotNull AggregateFilterStep
<T> withinGroupOrderBy
(OrderField<?>... fields) Add anWITHIN GROUP (ORDER BY …)
clause to the ordered aggregate function.
-
Method Details
-
withinGroupOrderBy
@NotNull @Support({AURORA_MYSQL,AURORA_POSTGRES,BIGQUERY,COCKROACHDB,CUBRID,DB2,DUCKDB,EXASOL,H2,HANA,HSQLDB,MARIADB,MEMSQL,MYSQL,ORACLE11G,POSTGRES,REDSHIFT,SNOWFLAKE,SQLDATAWAREHOUSE,SQLITE,SQLSERVER2012,SYBASE,TERADATA,TRINO,YUGABYTEDB}) @NotNull AggregateFilterStep<T> withinGroupOrderBy(OrderField<?>... fields) Add anWITHIN GROUP (ORDER BY …)
clause to the ordered aggregate function. -
withinGroupOrderBy
@NotNull @Support({AURORA_MYSQL,AURORA_POSTGRES,BIGQUERY,COCKROACHDB,CUBRID,DB2,DUCKDB,EXASOL,H2,HANA,HSQLDB,MARIADB,MEMSQL,MYSQL,ORACLE11G,POSTGRES,REDSHIFT,SNOWFLAKE,SQLDATAWAREHOUSE,SQLITE,SQLSERVER2012,SYBASE,TERADATA,TRINO,YUGABYTEDB}) @NotNull AggregateFilterStep<T> withinGroupOrderBy(Collection<? extends OrderField<?>> fields) Add anWITHIN GROUP (ORDER BY …)
clause to the ordered aggregate function. -
orderBy
@NotNull @Support({AURORA_MYSQL,AURORA_POSTGRES,BIGQUERY,COCKROACHDB,CUBRID,DB2,DUCKDB,EXASOL,H2,HANA,HSQLDB,MARIADB,MEMSQL,MYSQL,ORACLE11G,POSTGRES,REDSHIFT,SNOWFLAKE,SQLDATAWAREHOUSE,SQLITE,SQLSERVER2012,SYBASE,TERADATA,TRINO,YUGABYTEDB}) @NotNull AggregateFilterStep<T> orderBy(OrderField<?>... fields) Add anORDER BY …
clause to the ordered aggregate function. -
orderBy
@NotNull @Support({AURORA_MYSQL,AURORA_POSTGRES,BIGQUERY,COCKROACHDB,CUBRID,DB2,DUCKDB,EXASOL,H2,HANA,HSQLDB,MARIADB,MEMSQL,MYSQL,ORACLE11G,POSTGRES,REDSHIFT,SNOWFLAKE,SQLDATAWAREHOUSE,SQLITE,SQLSERVER2012,SYBASE,TERADATA,TRINO,YUGABYTEDB}) @NotNull AggregateFilterStep<T> orderBy(Collection<? extends OrderField<?>> fields) Add anORDER BY …
clause to the ordered aggregate function.
-