Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-novice by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group