Use an ORDER BY, like this example from the manual:
SELECT array_agg(a ORDER BY b DESC) FROM table;
More Related Contents:
- What is PostgreSQL equivalent to autoincrement?
- How do I specify a password to ‘psql’ non-interactively?
- INSERT with dynamic table name in trigger function
- psql: FATAL: Ident authentication failed for user “postgres”
- Use multiple conflict_target in ON CONFLICT clause
- PostgreSQL -must appear in the GROUP BY clause or be used in an aggregate function
- What is the format for the PostgreSQL connection string / URL?
- Go and IN clause in Postgres
- Where does PostgreSQL store the database?
- Is there a way to disable function overloading in Postgres
- Grant all on a specific schema in the db to a group role in PostgreSQL
- Can I make a plpgsql function return an integer without using a variable?
- Migrate database from Postgres to MySQL [closed]
- How can I start PostgreSQL on Windows?
- PostgreSQL – max number of parameters in “IN” clause?
- SQLAlchemy, Psycopg2 and Postgresql COPY
- How to find out if an upsert was an update with PostgreSQL 9.5+ UPSERT?
- Why can I create a table with PRIMARY KEY on a nullable column?
- Oracle SQL Developer and PostgreSQL
- PostgreSQL array of elements that each are a foreign key
- How to reset sequence in postgres and fill id column with new data?
- Differentiate inserted and updated rows in UPSERT using system columns
- Custom ORDER BY Explanation
- Configure JPA to let PostgreSQL generate the primary key value
- ERROR: unterminated quoted string at or near
- How can I send some http request from postgresql function or trigger
- Hashing a String to a Numeric Value in PostgreSQL
- Spring Docker container cannot access Postgres Docker container
- Format specifier for integer variables in format() for EXECUTE?
- PostgreSQL composite primary key