Re: ORDER BY DESC and NULLS LAST by default

Поиск
Список
Период
Сортировка
От Arjan Saly Consultancy (EU)
Тема Re: ORDER BY DESC and NULLS LAST by default
Дата
Msg-id 31B4CC5A-ADE1-42C9-8A89-8B1EC78D8571@arjansaly.eu
обсуждение исходный текст
Ответ на Re: ORDER BY DESC and NULLS LAST by default  (M Sarwar <sarwarmd02@outlook.com>)
Список pgsql-admin
You should be able to use the ORDER BY <sort_espression> ASC NULLS LAST clause, see this page in the manuals: https://www.postgresql.org/docs/current/queries-order.html

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@arjansaly.eu
l: https://nl.linkedin.com/in/arjansaly
w: https://www.arjansaly.eu/consultancy



Mail Signature.png

Op 27 okt 2023, om 16:17 heeft M Sarwar <sarwarmd02@outlook.com> het volgende geschreven:

I do not think that this is available in any of the databases.
Sarwar


From: Loles <lolesft@gmail.com>
Sent: Friday, October 27, 2023 10:16 AM
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
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!

Вложения

В списке pgsql-admin по дате отправления:

Предыдущее
От: Ron
Дата:
Сообщение: Rollback after "Connection timed out"?
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Rollback after "Connection timed out"?