I want to sort the rows inside the json_agg function.
I found this: PostgreSQL : select columns inside json_agg
Which gave me a solution to selecting specific columns for json_agg, but now I want to give the aggregated data a specific order. The "distinct" does work the "order by" does not.
json_agg(DISTINCT (colA, colB))
This does not:
json_agg(DISTINCT (colA, colB) ORDER BY colA ASC, colB ASC)
Is there a way to sort the aggregated data?