Re: "next" - Mailing list pgsql-novice

From Joel Burton
Subject Re: "next"
Date
Msg-id 20021202173827.GB11857@temp.joelburton.com
Whole thread Raw
In response to Re: "next"  (Joel Burton <joel@joelburton.com>)
List pgsql-novice
On Mon, Dec 02, 2002 at 12:18:37PM -0500, Joel Burton wrote:
> insert into train (depart,arrive) values ('2002-01-01 1:00
> PM','2002-01-01 2:00 PM');
>
> insert into trains (depart,arrive) values ('2002-01-01 1:00
> PM','2002-01-01 2:00 PM');
>
> insert into trains (depart,arrive) values ('2002-01-01 4:00
> PM','2002-01-01 5:00 PM');
>
> insert into trains (depart,arrive) values ('2002-01-02 4:00
> PM','2002-01-01 5:00 PM');
>
> insert into trains (depart,arrive) values ('2002-01-02 4:00
> PM','2002-02-01 5:00 PM');
>
> insert into trains (depart,arrive) values ('2002-01-09 4:00
> PM','2002-02-09 5:00 PM');
>
>
> joel@joel=# select * from trains;
>  id |       depart        |       arrive
>  ----+---------------------+---------------------
>  1 | 2002-01-01 13:00:00 | 2002-01-01 14:00:00
>  2 | 2002-01-01 16:00:00 | 2002-01-01 17:00:00
>  4 | 2002-01-02 16:00:00 | 2002-02-01 17:00:00
>  5 | 2002-01-09 16:00:00 | 2002-02-09 17:00:00
>
>
> Ok, so trains 2 and 4 have arrivals where the last departure is more
> than 7 hours away. And train 5 will also appear, since there is no
> departure after it.

...

> And we get train #1, which is the earliest train arrival that meets the
> requirements.

Eek! Need to get lunch before brain falls asleep. Train #3 disappeared
into a derailed insert statement, so if you cut & paste my data, your
trains 3 & 4 will be my 4 & 5.


And train #2, not #1, is the ultimate answer.

--

Joel BURTON  |  joel@joelburton.com  |  joelburton.com  |  aim: wjoelburton
Independent Knowledge Management Consultant

pgsql-novice by date:

Previous
From: Joel Burton
Date:
Subject: Re: "next"
Next
From: Mario Dávila Rangél
Date:
Subject: HOWTO return a resultset form SP?