Overriding natural order of query results for a subset

Поиск
Список
Период
Сортировка
От Laura Smith
Тема Overriding natural order of query results for a subset
Дата
Msg-id JMAUMif8HlhnMcFKC0RtswyGZHq3KNgCjtzOeXV4ISzy1aiG17q5KtvMMNu-t2Eeu2TWP4N-GG3o4Ruf62ng0Muxw5QfaG4Kh0s-3VluLSg=@protonmail.ch
обсуждение исходный текст
Ответы Re: Overriding natural order of query results for a subset  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: Overriding natural order of query results for a subset  (Michael van der Kolff <mvanderkolff@gmail.com>)
Re: Overriding natural order of query results for a subset  (Michael Nolan <htfoot@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Willy-Bas Loos
Дата:
Сообщение: Re: WAL accumulating, Logical Replication pg 13
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: Overriding natural order of query results for a subset