Re: problem selecting multiple records (again!)

From: Manuel Sugawara <masm(at)fciencias(dot)unam(dot)mx>
To: Nabil Sayegh <nsmail(at)sayegh(dot)de>
Cc: Giorgio Andreoletti - mentelocale <giorgio(dot)andreoletti(at)mentelocale(dot)it>, pgsql-novice(at)postgresql(dot)org
Subject: Re: problem selecting multiple records (again!)
Date: 2001-06-06 00:40:01
Message-ID: m3ae3m30gu.fsf@dep1.fciencias.unam.mx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Nabil Sayegh <nsmail(at)sayegh(dot)de> writes:

> On 05 Jun 2001 17:01:14 -0500, Manuel Sugawara wrote:
> >
> > something like
> >
> > select * from events where ref in (select distinct ref from events limit 3);
> >
> > will do what you want.
>
> Not exactly, he wanted the NEXT 3 events.

OK, I see; is not that simple eh?, but here is another idea, create a
view, something like:

create view events_v as select distinct on (ref) * from events where date >= now();

and then select limited to 3

select * from events_v order by date limit 3;

This may not do exactly what he wants but is closest solution i can
imagine ;-)

regards,
Manuel.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Rob Brown-Bayliss 2001-06-06 07:45:31 Re: PG_DUMP fails to load back in
Previous Message Nabil Sayegh 2001-06-05 23:48:15 Re: problem selecting multiple records (again!)