pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: Troels Arvin <troels@arvin.dk>
Cc: pgsql-sql@postgresql.org
Subject: Re: Quota query with decent performance?
Date: Tue, 18 Nov 2003 06:56:42 -0600
Message-ID: <20031118125642.GC30809@wolff.to> (raw)
In-Reply-To: <pan.2003.11.17.22.55.52.997736@arvin.dk>
References: <pan.2003.11.11.22.58.08.758402@arvin.dk>
	<Pine.BSO.4.44.0311111832190.19584-100000@detroit.arbor.net>
	<pan.2003.11.17.22.55.52.997736@arvin.dk>

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));



view thread (13+ messages)  latest in thread

Message-ID: <20031118125642.GC30809@wolff.to>
Permalink:  ../20031118125642.GC30809@wolff.to/
Also on:    postgresql.org/message-id/20031118125642.GC30809@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, troels@arvin.dk
  Subject: Re: Quota query with decent performance?
  In-Reply-To: <20031118125642.GC30809@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox