In the following request:
SELECT
myid,
min(name) AS name,
array_agg(array[zip, city])) AS city
FROM my_table
WHERE name LIKE 'Doe'
GROUP BY myid
LIMIT 10
I get the following result:
+-------+------+-------------------+
| myid | name | city |
+-------+------+-------------------+
| A123 | Doe | {{69,"Groville"}} |
| B456 | Doe | {{NULL,NULL}} |
+-------+------+-------------------+
How can I get rid of the NULL values and get an empty field for city instead ?
=== EDIT ===
Replaced (array_agg(name))[1] AS name by min(name) AS name in the query, as suggested by @a_horse_with_no_name.
min(name)instead of first aggregating all names and then pick one