Skip to content
masterclass Buddy

PostgreSQL · Function

string_agg

string_agg joins non-null values into one string, placing a delimiter between values. Use an ORDER BY clause inside the aggregate when the order must be controlled.

Last updated

Syntax

string_agg(value text, delimiter text) → text
string_agg(value bytea, delimiter bytea ORDER BY input_sort_columns) → bytea

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • array_agg
  • xmlagg
  • ORDER BY
  • COALESCE

Source: PostgreSQL: Documentation: 18: 9.21. Aggregate Functions. Checked 2026-11-03.