Skip to content

Instantly share code, notes, and snippets.

@nitindhar7
Created October 22, 2011 00:24
Show Gist options
  • Save nitindhar7/1305333 to your computer and use it in GitHub Desktop.
Save nitindhar7/1305333 to your computer and use it in GitHub Desktop.
Array Agg PSQL
SELECT user.id AS user_id, ARRAY_AGG(group.id) AS group_ids
FROM users
LEFT JOIN groups ON group.user_id = group.id
GROUP BY user.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment