Re: Overriding natural order of query results for a subset - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Overriding natural order of query results for a subset
Date
Msg-id a20f32d7-a1de-89c6-ef5e-6141086dc313@aklaver.com
Whole thread Raw
In response to Re: Overriding natural order of query results for a subset  (Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>)
List pgsql-general
On 5/29/21 9:34 AM, Laura Smith wrote:
> 
> ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
> On Saturday, 29 May 2021 17:06, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
> 
>> On 5/29/21 9:00 AM, Laura Smith wrote:
>>
>>> I did try "nulls last" but will give it another go, maybe I messed up on the ordering of clauses.
>>
>> Unless the fields you are ordering on contain NULLs I'm not sure how
>> this is going to deal with your issue.
>>
> 
> 
> Reading between the lines of the poster who suggested it, I'm guessing the suggestion was to add an "int" column,
mostof which is null except for numbers where needed for ordering and then having "order by vip_num_order,order by
last_name"in my select clause.
 
> 

That's a whole lot of reading:) If you are going to go that route use 
NOT NULL and a DEFAULT of 0. Then you are not depending on a lack of 
information and you can use explicit number setting to create your ordering.

-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: Laura Smith
Date:
Subject: Re: Overriding natural order of query results for a subset
Next
From: Michael Nolan
Date:
Subject: Re: Overriding natural order of query results for a subset