However, if this doesn't work well, you might check your localisation and collation settings as the way a database sorts depends on these settings. They can be changed on OS level, in the database configuration and on session level, but you can also use the COLLATE statement in your query. I would expect PostgreSQL to override these settings when the ORDER BY …. NULL LAST (or FIRST) clause is used, but since I’ve never used this option, I can’t tell for sure. I have seen on other applications (not postgres) that if OS localisation or collation does not match the applications localisation/collation, things may get messed up. Mostly with special characters, but sometimes with sorting as well. To my experience this seems to be more of an issue on Windows machines than on Linux based machines.
See https://www.postgresql.org/docs/current/locale.html#LOCALE-BEHAVIOR for more information on localisation and collation in PostgreSQL.
Hope this helps!
Kind Regards,
Arjan Saly Database & Business Intelligence Specialist Arjan Saly Consultancy
e: consultancy@xxxxxxxxxxxx l: https://nl.linkedin.com/in/arjansaly w: https://www.arjansaly.eu/consultancy
Op 27 okt 2023, om 16:17 heeft M Sarwar <sarwarmd02@xxxxxxxxxxx> het volgende geschreven:
I do not think that this is available in any of the databases. Sarwar
From: Loles <lolesft@xxxxxxxxx> Sent: Friday, October 27, 2023 10:16 AM To: pgsql-admin@xxxxxxxxxxxxxx <pgsql-admin@xxxxxxxxxxxxxx> Subject: ORDER BY DESC and NULLS LAST by default Hi!
Can the server be configured so that the default ORDER BY option is DESC instead of ASC?
And to make it NULLS LAST instead of NULLS FIRST?
Happy weekend and Thank you very much!
|