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