Re: configure postgtresql to order NULLS FIRST instead of the default NULLS LAST

Jay Riddle <[email protected]>
Newsgroups gmane.comp.db.postgresql.novice
Message-ID <[email protected]>
Maybe something like this will work for you
....ORDER BY CASE WHEN SomeColumn IS NULL THEN 1 ELSE 0 END, SomeColumn

      From: Vik Fearing <[email protected]>
 To: David G. Johnston <[email protected]>; john snow <[email protected]> 
Cc: pgsql-novice <[email protected]>
 Sent: Friday, January 4, 2019 1:33 AM
 Subject: Re: configure postgtresql to order NULLS FIRST instead of the default NULLS LAST
   
On 04/01/2019 08:09, David G. Johnston wrote:
> On Thursday, January 3, 2019, john snow <[email protected]
> <mailto:[email protected]>> wrote:
> 
>    is there a setting that is available for me to use to configure
>    Postgresql to order NULLS FIRST by default instead of NULLS LAST?
> 
> 
> No there is not and likely never will be as such an option introduces
> undesirable variability.


That, and the spec forbids it.

"If <null ordering> is not specified, then an implementation-defined
<null ordering> is implicit. The implementation-defined default for
<null ordering> shall not depend on the context outside of <sort
specification list>."
-- 
Vik Fearing                                          +33 6 46 75 15 36
http://2ndQuadrant.fr     PostgreSQL : Expertise, Formation et Support
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.