Aggregate · Window
Aliases: listagg
NULL values are skipped; NULL delimiter is rejected.
Syntax
A window function keeps each input row and adds a result for that row. PARTITION BY groups rows with matching values; without it, all input rows form one group.
String agg (aggregate)
- A literal row limit can be the second argument when the delimiter is omitted.
String agg window
- Window usage requires STRING_AGG with all three arguments.
- Use a frame that includes all rows in the group or starts at the first row (
UNBOUNDED PRECEDING). Sliding frames that drop earlier rows are not supported.
Arguments
String agg
String agg window
Returns
- Type: STRING
- NULL behavior: NULL values are skipped; NULL delimiter is rejected.
- Empty input: Returns NULL on empty/all-NULL input.
Properties
Usage notes
- max_elements limits input elements, not output characters or bytes; -1 means unlimited.
- If omitted, the delimiter is ”. Supply a STRING literal; a delimiter expression currently uses ” instead of its value.
- LISTAGG has no row-limit argument. STRING_AGG accepts a literal row limit as its second or third argument.
- DISTINCT removes duplicates in grouped aggregation. Do not use it to remove duplicates in a window call.
Examples
STRING_AGG row limit
STRING_AGG over all rows in each group
Limitations
- Sliding frames that drop earlier rows and RANGE frames with numeric or time offsets are not supported.
- DISTINCT WITHIN GROUP ordering must use the aggregated expression.
- LISTAGG window calls currently fail. Use STRING_AGG(value, delimiter, max_elements) for window usage.
Last modified on October 15, 2026