PostgreSQLAggregate FunctionsARRAY_AGG
STRING_AGG

ARRAY_AGGAggregate Functions

JSON_AGG

Aggregates values into an array.

Syntax

ARRAY_AGG(expr [ORDER BY ...])

Example

Enter values below to update the example in real time.

department_id
employee_id
emp_ids
employees
-- 부서별 직원 ID 배열
SELECT department_id,
       ARRAY_AGG(employee_id ORDER BY employee_id) AS emp_ids
FROM employees
GROUP BY department_id;