From: | Joel Burton <joel(at)joelburton(dot)com> |
---|---|
To: | Joel Burton <joel(at)joelburton(dot)com> |
Cc: | Malcolm Hutty <msah-postgresql(at)hutty(dot)com>, pgsql-novice(at)postgresql(dot)org |
Subject: | Re: "next" |
Date: | 2002-12-02 17:38:27 |
Message-ID: | 20021202173827.GB11857@temp.joelburton.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)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(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Independent Knowledge Management Consultant
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Burton | 2002-12-02 18:16:08 | Re: "next" |
Previous Message | Joel Burton | 2002-12-02 17:18:37 | Re: "next" |