PostgreSQLAggregate FunctionsSTRING_AGG
MAX

STRING_AGGAggregate Functions

ARRAY_AGG

Concatenates strings with a separator.

Syntax

STRING_AGG(expr, sep [ORDER BY ...])

Example

Enter values below to update the example in real time.

department_id
last_name
members
employees
-- 부서별 직원 목록
SELECT department_id,
       STRING_AGG(last_name, ', ' ORDER BY last_name) AS members
FROM employees
GROUP BY department_id;