STRING_AGG()
STRING_AGG() is a SQL function in the Aggregate Functions category. PostgreSQL aggregate that concatenates values into one string with a delimiter. The syntax is STRING_AGG(expression, delimiter [ORDER BY column]). It accepts expression, delimiter. It returns concatenated string. A typical example: SELECT department, STRING_AGG(name, ', ' ORDER BY name) AS employee_list FROM employees GROUP BY department; -- Sales: Alice, Bob, Charlie A close relative is COUNT(), which returns the number of rows (or non-NULL values) in a group. A close relative is SUM(), which returns the sum of all non-NULL values in a group. Works with numeric columns. A close relative is AVG(), which returns the average (mean) of all non-NULL values in a group. More about this category: Aggregation functions — COUNT, SUM, AVG, MIN, MAX, GROUP BY, HAVING. Related Aggregate Functions entries: COUNT(), SUM(), AVG(), MIN(), MAX(), GROUP_CONCAT() / LISTAGG(), VARIANCE() / VAR_SAMP(), STDDEV() / STDDEV_SAMP().