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

From: Jay Riddle <jcriddle4(at)yahoo(dot)com>
To: Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, john snow <ofbizfanster(at)gmail(dot)com>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: configure postgtresql to order NULLS FIRST instead of the default NULLS LAST
Date: 2019-01-04 10:31:17
Message-ID: 1799053763.6104245.1546597877186@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Maybe something like this will work for you
....ORDER BY CASE WHEN SomeColumn IS NULL THEN 1 ELSE 0 END, SomeColumn

From: Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>
To: David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>; john snow <ofbizfanster(at)gmail(dot)com>
Cc: pgsql-novice <pgsql-novice(at)postgresql(dot)org>
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 <ofbizfanster(at)gmail(dot)com
> <mailto:ofbizfanster(at)gmail(dot)com>> 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

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Stephen Froehlich 2019-01-04 13:24:53 WAL on zfs Settings
Previous Message Vik Fearing 2019-01-04 09:33:14 Re: configure postgtresql to order NULLS FIRST instead of the default NULLS LAST