Welcome to the CHICKEN Scheme pasting service

Array_agg ordering not working added by sjamaan on Fri Feb 1 15:45:36 2019

binder-test=# select * from testapp_zoo;
  id  | name |
------+-------
 5589 | test |
(1 row)

binder-test=# select * from testapp_animal order by name;
  id   | name | zoo_id |
-------+------+---------
 12066 | a    |   5589 |
 12065 | b    |   5589 |
(2 rows)

binder-test=# SELECT "testapp_zoo"."id", ARRAY_AGG("testapp_animal"."id" ORDER BY "testapp_zoo"."name") FILTER (WHERE "testapp_animal"."id" IS NOT NULL) AS "animals___annotation" FROM "testapp_zoo" LEFT OUTER JOIN "testapp_animal" ON ("testapp_zoo"."id" = "testapp_animal"."zoo_id") GROUP BY "testapp_zoo"."id" ORDER BY "testapp_zoo"."name" ASC;
  id  | animals___annotation 
------+----------------------
 5589 | {12065,12066}
(1 row)

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Type in the text below:
                      _          _ 
  __ _ _ __ _   _ ___| |_ _   _ (_)
 / _` | '__| | | |_  / __| | | || |
| (_| | |  | |_| |/ /| |_| |_| || |
 \__, |_|   \__, /___|\__|\__, |/ |
 |___/      |___/         |___/__/ 
Visually impaired? Let me spell it for you (wav file) download WAV