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

From Laura Smith
Subject Overriding natural order of query results for a subset
Date
Msg-id JMAUMif8HlhnMcFKC0RtswyGZHq3KNgCjtzOeXV4ISzy1aiG17q5KtvMMNu-t2Eeu2TWP4N-GG3o4Ruf62ng0Muxw5QfaG4Kh0s-3VluLSg=@protonmail.ch
Whole thread Raw
Responses Re: Overriding natural order of query results for a subset
Re: Overriding natural order of query results for a subset
Re: Overriding natural order of query results for a subset
List pgsql-general
Hi

I've got a bit of a puzzle that I'm not quite sure how to approach.

Let's say I've got a table of bios, so :

create table bios (
first_name text not null,
last_name text not null,
person_title text,
person_short_bio text
);

Now, the "natural order" would be a standard "select * from bios order by last_name".  Basic stuff, no problem.

The problem is that my use-case calls for a scenario where due to protocol certain people may be designated as "VIP"
andtherefore need to appear at the top.  In addition, protocol may dictate that those "VIP" people themselves may
(sometimesbut not always) need to be ordered in a specific manner. 

Bear in mind that there may be a large enough number of people in this table that the naïve approach of manually
assigningeveryone an order is neither practical or desirable.  Hence the need for an "override" which would mean only a
subsetof people would need specific parameters. 

Any ideas ?

Thanks !

Laura





pgsql-general by date:

Previous
From: Willy-Bas Loos
Date:
Subject: Re: WAL accumulating, Logical Replication pg 13
Next
From: "David G. Johnston"
Date:
Subject: Re: Overriding natural order of query results for a subset