Sort a text aggregate created with array_agg in postgresql

前端 未结 6 2100
傲寒
傲寒 2021-02-05 04:42

I have a table in postgresql. The following table \"animals\" will do to explain my problem:

name
------
tiger
cat
dog

Now I am using the follo

6条回答
  •  执念已碎
    2021-02-05 05:00

    To update on this question, Snowflake has implemented array sorting:

    SELECT
        array_sort(array_agg("name")
    FROM
        animals;
    

    Can also use array_sort_by to sort an object

提交回复
热议问题