So I have a table that has EMAIL and Order ID.
EMAIL | id
--------------
[email protected] | 1
[email protected] | 2
[email protected] | 3
And I need to SELECT it so that I'd have email column that is distinct and ids column that is array of int's
EMAIL | ids
--------------
[email protected] | [1,2]
[email protected] | [3]
I use PSQL 9.3. I looked at aggregate functions, but since I'm not too good with SQL atm, I didn't really understand them. My code so far is:
SELECT DISTINCT ON (email) email
FROM order
WHERE date > '2013-01-01';