So basically I have 2 polygon tables, tableA that I want to update with the aggregated strings from tableB. tableB has 2 columns
TableB is structure something like
viable | fruit_id
yes | banana1
no | apple2
maybe | watermelon1
no | peach3
My update query looks like:
update TableA a set
fruitids = (select string_agg(fruit_id, ', ' order by fruit_id)
from tableB b st_contains(b.geom, a.geom))
But this will just return me the fruit ids in alphabetical order. How can I make it so that it will list the viable ones first? In this case my intended output would be:
banana1, watermelon1, apple2, peach3