I am tring to insert data to PostgreSQL table from array. My next sql query raise error. Why I can't use ARRAY_AGG in UNNEST?
INSERT INTO surveys_questions_relationship(survey_id, question_id)
SELECT '9bef1274-f1ee-4879-a60e-16e94e88df38' ID, x
FROM UNNEST(
SELECT ARRAY_AGG (QUESTION_ID)
FROM factors_questions_relationship
WHERE FACTOR_ID = 10
) x
Subquery inside UNNEST return list of ids {1,2,3,4,5,6}. How correctly create array to UNNEST?