on-internet
← Community

Interleaving array_agg in postgres

Stack Overflow ·

I have a postgres query in which I want to interleave my array_agg statements : SELECT client_user_id, (array_agg(question), array_agg(client_intake_question_id), array_agg(answer)) as answer FROM client_intake_answer LEFT OUTER JOIN client_intake_question ON client_intake_question.id = client_user_id GROUP BY client_user_id Gives me the following: 5 | ("{""Have you ever received counselling?"",""Have you ever received counselling or mental health support in the past?""}","{1,2}","{yes,no}") I would like the results to be: 5 | ("{""Have you ever received counselling?", 1, "yes"",""Have you eve

Comments

Sign in or sign up to comment and upvote.

No comments yet.