Re: Quota query with decent performance?

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: Quota query with decent performance?
Дата
Msg-id 20031118125642.GC30809@wolff.to
обсуждение исходный текст
Ответ на Re: Quota query with decent performance?  (Troels Arvin <troels@arvin.dk>)
Список pgsql-sql
On Mon, Nov 17, 2003 at 23:55:53 +0100, Troels Arvin <troels@arvin.dk> wrote:
> On Tue, 11 Nov 2003 18:49:31 -0500, Chester Kustarz wrote:
> 
> [... discussion of top-n query (where n=3) ...]
> 
> > select *
> > from person
> > where age <=
> > (select age from person order by age limit 1 offset 2);
> 
> It fails when the cardinality of person is less than 3 (returns empty
> set). My solution is this, which is not as beautiful any more:

Used that way the subselect value will be null if there are no matching
rows. This should allow you to do something like:

select *
from person
where not isfalse (age <=
(select age from person order by age limit 1 offset 2));


В списке pgsql-sql по дате отправления:

Предыдущее
От: Michele Bendazzoli
Дата:
Сообщение: Re: Multicolum index and primary key
Следующее
От: Troels Arvin
Дата:
Сообщение: Re: Quota query with decent performance?